For the most part is has a built in grinder, which dumps the coffee in to some type of a group. Some groups run on a Worm gear that moves the group up on to a stationary piston at the top. Then the machine pumps water through this group and out the top of the piston in to another tube running to the front dispensing head.
Or if it is more complex the grinder dumps the coffee in to a carousel, which then turns 90 degrees to a set of pistons. One will come up while the other comes down and compresses the espresso. Then again a tube leads from either the top or bottom and moves the espresso to the dispensing head.
Then they both have some type of ejection system to get rid of the puck. A lot of Worm gear machines have a lever that pushes the puck out of the group head after the machine gets to the bottom of the gear. Carousel machines have another piston that comes down and pushes the puck out.
For the most part this is espresso 101, it really is a lot more technical then this I just thought you would like the quick version.
Machines that also produce the milk drinks rely on milk in a jug or have a built in refrigerator. The easiest way to say this is imagine a T, as steam passes by on the top of the T it is pulling milk through the vertical shaft. Add a pinch valve to slow down how much milk it can pull and this is what heats the milk.
Again this is a very simple version. Frothing heads are a lot more complex then that.