The tap is a valve. The pipes are filled with water under pressure. Opening the valve releases the pressure and allows the water to flow to you. Pumps in the distribution centers ensure that more water flows in to replace that which you remove, and keep the pressure at the proper level.

The reason it takes hot water a while to get hot is that while the water heater may have hot water stored, the pipes themselves are not heated, so the colder water must be flushed out first.