Use yEd's snap line feature (5th tool bar button from the right) for this purpose. With snap lines enabled, use the mouse to drag the second node close to the first and let the snap lines handle the fine tuning.
Alternatively, select the second node and enter the desired x or y coordinate in the corresponding text fields in the properties view in yEd's lower right corner.