I just re-watched TNG “In Theory” (S04E25) and Data says that the door to his quarters is set to only allow humanoids to enter or leave when Geordie finds Spot in the hall.
Whilst I get that it would be dangerous for Spot to wander the ship freely I think it’s kind of mean to keep him locked in a small room like that forever. There doesn’t seem to be any cat toys in the room but maybe the computer is capable of some sort of environmental enrichment we can’t immediately see.
To be fair, you can’t treat Spot like an outdoor cat on a space ship. Unlike kids there’s no one assigned to Spot to keep track of them in an emergency.
And before you say well Data is responsible for that, keep in mind data will pretty always have his attention monopolized by an emergency on this ship. So the best thing for Spot is to be in a known location.