When traffic comes into EX 4550 on left. it arrives on interface xe-0/0/2 which is in vlan 1701.
1. vlan 1701 is configured on interface xe-0/0/4 ( cost 2000 )and it is also passed through ae0.0 ( cost 1000 ) which is a trunk
As per my understanding when traffic comes into switch on interface xe-0/0/2 which is in vlan 1701 , it passes out through ae0.0 as its cost is lower than what is configured on xe-0/0/4. Is my understanding correct ? Or does it passes through interface xe-0/0/4 to packet shaper and traffic is received on interface xe-0/0/3 on vlan 1419 and then passes through ae0.0 ?
I assume you are looking at how STP is working for your setup here. But the section of the diagram shown has no loops and you don't mention where the destination mac address port is that the device is trying to reach so the analysis will be incomplete.
The basics to remember is that these costs are used to decide which ports are not used at all for the vlan and put into blocking mode to avoid the loop. Once a port is in blocking no traffic will cross that port until the other path fails and is no longer available.
So the place to start in knowing what your layer two paths are is to use the monitoring commands for the version of STP you are running to confirm where the bridge is and which ports are blocking to prevent loops.
As Steve mentioned, these costs are used by STP to chose which ports are forwarding traffic and which ones are blocking. In your topology, the EX switch on the right wil look at the cost of the interfaces advertised by the other EX (on the BPDUs), to chose which port will be its root port (closest to the root bridge). That port will be the one forwarding traffic between the two EX switches.
With regards to traffic, broadcast traffic or unknown unicast (when the destination MAC has not been learned yet) will be sent out of all interfaces that are part of the same VLAN, and are in the forwarding state. Unicast traffic is only forwarded out of the interface where the destination is located.