We don’t really replace the voltage sources with shorts rather we make the voltage of the voltage sources zero volts. An ideal voltage source has zero internal impedance by definition of being “ideal”, so if we reduce its voltage to zero, we are left with a zero impedance source, which is a short circuit. An ideal voltage source can produce whatever current it needs to keep its terminal voltage at its specified value.
Circuit of Ideal Voltage and Ideal Current Source is given below.
For Ideal Voltage Source, series resistance = 0 while for Ideal Current Source parallel resistance is infinite.
Similarly, we don’t replace a current source with an open circuit rather we make the current of the current source zero. An ideal current source has infinite internal impedance, so when we make its current zero, we are left with an infinite impedance, which is an open circuit. An idea current source has the property that it can produce whatever voltage it needs to force its specified current to flow through it. Of course ideal voltage and current sources can only be approximated in real circuit hardware, but the concept is very useful for circuit analysis.