This page of the Little Nightmares 2 guide contains the exact location and description of all the Hats you can obtain in the second stage of the game: Orphanage.
Location: Chapter 2, entrance to the orphanage.
In order to reach the hat, you have to jump onto the dumpster. The easiest way to do this is to jump over the barrier near the door. Pick up the hat and it will appear in your inventory.
Location: Chapter 2, library.
In order to reach the new headwear, you will need to move the ladder to the 3rd rack.
As soon as you pick up the hat, it will go into your inventory. You need to have a solid look around. Due to its color, it is not easily noticeable among the other books.