There are two main kinds of effects, one-shot effects and continuous effects. The phrase "you may cast" appears in both of those effects. If it is a one-shot effect, you cast the spell immediately, and standard type-based timing restrictions do not apply. If it's a continuous effect, those timing restrictions do apply.
The rule for determining what kind of effect a "you may cast" instruction is is actually pretty simple:
If the instruction is on a spell or in an activated or triggered ability, then it is a continuous effect if it has a duration ("this turn", "until end of turn", "as long as [that card] remains exiled", etc). Otherwise it is a one-shot effect.
Any other "you may cast" effect is a continuous effect.
The reason you can ignore standard timing restrictions only with the one-shot version of this effect is that they are not really timing restrictions, they are timing permissions. For example, rule 302.1 says
A player who has priority may cast a creature card from their hand during a main phase of their turn when the stack is empty. Casting a creature as a spell uses the stack. (See rule 601, “Casting Spells.”)
The rule permits you to cast creature spells at specific times, but it does not prohibit you from casting the spells at other times. A one-shot "you may cast" effect instructs you to cast the spell at another specific time: while that effect is resolving. A continuous "you may cast" effect, on the other hand, allows you to cast a spell within its duration, but it's not giving you any new permission to cast it at a specific time so you can still only cast it when you would normally be able to cast that kind of spell.
For contrast, you do still have to obey actual timing restrictions. Curtain of Light has the text
Cast this spell only during combat after blockers are declared.
If a one-shot effect instructs you to cast Curtain of Light outside of combat, you cannot do so, because Curtain of Light's ability explicitly restricts when you can cast it.