Since it's early days, the MCU has tried to follow rules to attempt to tell as grounded and realistic stories as possible. The MCU soon started moving into sci-fi more and more though, up to a point where aliens, the multiverse and eons old cosmic beings don't feel out of place anymore. And this also meant it started to play more loose with the rules.
However, moving into sci-fi does not mean realism is lost altogether. Science-fiction is fiction, but it could still be made to feel real or grounded if it follows certain certain rules. This is where soft and hard rules come it. The former means the rules are much less strict, something the MCU has come to rely on, whereas the latter means the rules are very strict, like in The Expanse.
Marvel Cinematic Universal rules
Soft rules are prevelant in movies like Thor and Guardians of the Galaxy. Especially Thor, which is almost fantasy with it's gods and magic. Thor might explain in his first movie they aren't gods and their magic is just really advanced science, while Ragnarok turns around on this later. Guardians of the Galaxy also has advanced science, but started to move into fantasy more with Ego's powers. And fantasy in the MCU has only been explored more, like with Gods having Avatars, as seen in Black Panther and Moon Knight.
Hard rules come in with the Pym Particles. While it is said space between atoms can be decreased and retains it's mass, Ant-Man throws this out in favor of the rule of cool anyway, as is seen with the tank keychain being light in it's shrunken form. The particles also allow for time-travel through the Quantum Realm in Avengers Endgame. Even though the realm is fictional, the rules of time travel aren't (as far as theory allows). However, the MCU is playing more loose with it within multiverse territory.
Science f(r)iction
A show that does try to follow hard sci-fi rules as much as possible, is The Expanse. Aside from a few fictional elements in the story, like the Epstein Drive, it abides to rules rooted in real-life physics. There is no sound in space, artifical gravity comes from acceleration or centrifugional force, conservation of energy is used to move in zero G, radio contact takes longer in relation to the distance it takes light to travel, etc. Even though it limits itself by following these hard rules, The Expanse is very scientifically accurate (1).
Using scientific concepts doesn't mean scientific accuracy though. In Avatar, humans are able to send multiple ships to a far away star system to mine an element that can counter the ongoing energy crisis. However, this trip itself costs massive amounts of energy, including the very-hard-to-obtain Dark Matter (2). In The Way of Water, humans return to harvest a liquid to counter aging while they already clearly mastered cloning and mindtransfer. This makes the trip for an anti-aging serum redundant as well.
Fantastical elements
A solution to play with rules more is fantasy. This doesn't mean all rules can be thrown out the window though. Fantasy still follows rules, as can be seen in the Critical Role web series. The series is based on the set of rules that come with Dungeons & Dragons 5e, although these rules are more focused on game mechanics. As for the worldbuilding though, Critical Role tries to stay within the confines of it's lore as much as possible (3).
Fantasy and science-fiction aren't mutually exclusive though. The Destiny and Star Wars franchises both have common sci-fi elements and rules like space travel, faster-than-light communication, and aliens, but also very fantastical elements like magic (abilities and the force), dark lords (Savathun and Darth Vader) or even direct fantasy tropes (save the princess from the dark lord's tower in A New Hope). Like Thor, they are more science-fantasy. But whether it is sci-fi, fantasy, or both, the MCU still has rules to follow.