The first circuit turns the high level (about 5V) in a high impedance out and does not change the low level.
The second turns the low level (~0V) a high impedance out and does not change the high level.
This can be useful to make AND and OR logics, respectively, without multi-inputs IC's.
(Also known as Open Colector)