I'm new to the keyboard and am learning it myself. However, I've learnt Indian classical for three years. I want to know if a song that I play has to be played with the same fingers every time. If not, how will I ever develop muscle memory if I keep switching fingers to play the same notes?
You are overthinking this.
You are free to use whichever fingers you like when playing a piece but obviously some fingerings will work better than others.
What you need to do is to find a fingering that works for you and then try to always do that. Your "muscle memory" will simply work when you have practiced enough.
If you find a passage where there are two or more fingerings that work well for you then you simply need to select one and decide to use it. Maybe write in a few numbers on the page as a reminder.
We try to find a good fingering - that might mean 'good for YOU' considering your hand size - and stick to it. Not because it's a 'rule', but because it's effecient! You don't want to be hunting for each note every time you play the piece! Let your hands learn where to go, then your playing can become fluent.
Think of it this way. You make a journey to somewhere. Ten times, a different way each time. Will you know the way there? Or ten times the same way. Will you then know the way there?
Humans often learn by repetition. (Yes, some learn the hard way, but that's their problem!). By repeating the same action, whatever it is becomes ingrained more quickly. So why make any learning process longer than it needs to be?
Yes, it is fine, to a certain extent. I have been playing piano for over ten years and often I will switch between playing a chord 1-2-5 and 1-3-5, for no particular reason at all. However, like other answers have pointed out, you should still attempt to find the best fingering for yourself, one that is the most natural and comfortable. Occasionally, you might find multiple different fingerings that work equally well, and in that case, feel free to use any of them.