What's beneath the tiles of a bathroom?
It depends on if your tile was properly installed.  More variation than you would hope in that regard.

Floor applications

The layers of a properly-installed tile floor would be as follows, from top to bottom:


Tile and grout
Thinset mortar (the "glue" you are talking about)
Cement backer board
Thinset mortar
Subfloor
Floor joists


Thinset mortar is usually polymer-fortified to give it some flexibility, which helps prevent the movement of the substrate from affecting the tiles.

Backer board (such as Durock, HardieBacker, or WonderBoard) is like a sheet of concrete that is fairly impervious to water (though not water-tight).  It doesn't rot, warp, grow mold, or deteriorate when subject to water or moisture, and is a more stable substrate for tile than wood-based products like drywall, plywood, or OSB.

The backer board is always screwed to the subfloor, but I was taught to also bed it in a layer of thinset - sort of a "glue and screw" method for cement board.  The thinset helps fill in any irregularities in the subfloor so that the resulting tile installation is solid.

Beneath all that is the subfloor sheeting, attached to the floor joists.  If the subfloor is concrete, you don't need the backer board and can adhere the tile directly to the concrete.  In either case, the floor isn't strictly waterproof, but little enough water will make its way to the subfloor that it poses no problems.  Proper sealing of the grout will minimize the amount of water that makes its way through the first layer of floor.

Wet-area applications

In a shower or other area that is repeatedly exposed to water, you'll have a waterproof lining or membrane between the backer board and the studs (in the walls) and in the shower pan to prevent water from getting into places it shouldn't be.

Edit per comments:

Sometimes you'll see shower wall tiles adhered directly to drywall or "green board", which is a more resilient type of drywall.  It's not the best practice due to moisture concerns with the paper facing, but it's not always a problem.  Given the option to replace the drywall or green board with cement backer board (such as during a remodel), I personally would always choose to do so for peace of mind.

Sometimes, in place of a liner, a membrane-forming coating like RedGuard is used under the tile and mortar on the walls and floor.  When used correctly, this can replace the traditional sheet products.

Wall applications

Wall tiles are more commonly installed with a product called "mastic", which is more of an adhesive than thinset mortar.  It doesn't build or bed as well as thinset, so it's generally not suitable for floors or particularly heavy tiles.  You'll commonly find it used to adhere decorative tile backsplashes directly to drywall, which is acceptable as long as the drywall is sealed (painted).

I think that covers most of it.  If I've made any grave errors, please let me know.  My source for all of this is my former direct supervisor at Home Depot, who was a professional floor layer for about 25 years.  I no longer work there.