Is it possible to train your cat/pet to not press buttons at night?

My question is the title. I didn’t think it was possible but I saw someone on Instagram say their cat knows not to press buttons at night. So I was wondering how someone would train that or does that just come naturally to some pets?