There’s a whole chapter dedicated to spellcasting rules. There’s a fair number of steps involved beyond just choosing which spell you want to cast. There’s a wide variety of reasons that might not work, especially since there no rule that allows you to change what you’re casting after you start.