There are several types of ultrasound images. The most familiar for medical imaging is probably the B-mode type. This type of device uses a linear array of transducers to generate sound waves and to detect the reflected signal which is then processed to form a 2D cross-section or planar image of the tissues being scanned. When a sound wave passes into an area of different density or acoustic impedance part of it is reflected. The greater the difference in impedance, the stronger the return. The time delay and magnitude of the return signal (echo) are processed to determine the brightness of each image pixel. The processing algorithms are too complicated for this venue but in short the magnitude of the return gives an indication of the edges or interfaces between different tissues and structures while the delay time gives the distance or depth within the body.
Modern devices use phased array transducers to aim and focus sound pulses. Pulsed Doppler is used to determine frequency shifts which can be used along with the time delay, and the assumption that sound travels at a constant velocity of 1540 m/s, to calculate relative motion which can be displayed as a moving image using directional Doppler.
In short, each pulse is either aimed in a specific direction or produced by one of an array of transducers and the reflection is from that same direction.