Any section of the rope can be considered as a Free Body. If the section is not accelerating then the horizontal and vertical components of force on it are balanced.
If there are no forces external to the rope acting horizontally on the section, then the forces from the rope at the left and right (ie tension) must be equal. If the rope has mass then there is an external force acting vertically, so the forces on the section from above and below will differ by the weight of the section of rope.
The horizontal component of tension is not constant if the rope is accelerating horizontally - eg oscillating or rotating.