These are mezuzah cases. They house & protect a piece of parchment with the Shemah written on them. The Shemah is one of Judaism's holiest & most important prayers. It’s first line is "Hear, O Israel: the LORD our God, the LORD is one". It is used to bless the house and the room that one enters.
It is customary to touch a mezuzah with your fingers & then touch those fingers to your lips as you enter or
exit a room or house.
A mezuzah is afixed 2/3 of the way up the right side of all doorways in a house. This does not include bathrooms. Closets only require a mezuzah if the closet is "large enough for someone to dwell".