This school building is 37 years old.

This is a 37-year-old school building.

The boy is 13 years old.
He is a 13-year-old boy.

The is 170 cm tall.
He is a 170 cm-tall boy.

----------------
Is each pair the same and grammatical?

Yes they are all the same and grammatical -- except the last one should be:

The boy is 170 cm tall.
He is a 170-cm-tall boy.