TNG in particular did a great job of stretching the characters by building them up to a definitive version and then showing us, in one way or another, a variant or situation that completely shatters that image. Data and Lore. Alternate Riker. Broken Picard. Troi and Lwaxana. Worf and also Worf but later.
Yeah it’s a “read the room” kind of thing.
There’s a group that would be annoyed by immersion-breaking 4th wall jokes, and there’s another group that would be relieved by the tension and pressure to perform being broken. Everyone’s going to have slightly different comfort levels so there’s always some compromise on the tone of a campaign.