You can use planning which happens in an earlier session
If the players' planning happens in a session prior to the one with the actual quest, your planning for the respective session won't change much. Normally, you create a basic outline (heist on a moving vehicle). Then you create different encounters and challenges that you envision appearing on the path through the adventure. The difference is just, that your players create the path here.
Tricks for planning less constrained adventures.
Making things work on the fly is more difficult, but there are strategies to make it work.
Make content by impact and difficulty
Even if you have no exact idea on the path through the adventure and you let things unfold as they come, you will always have some ideas on what is important. When creating content beforehand there are two important questions to ask:
What is the probability that this will come up?
How difficult is it to make such a thing on the fly?
There more likely something will come up and the more difficult it is to make while running the game, the more reason you have to have it prepared.
Me, for example, I can usually make a combat encounter in under one minute, but not the stat blocks which will take several minutes each. Therefore I create some stat blocks which fit the adventure and choose the monsters in a specific encounter while running the game.
What is or is not easy to improvise changes from person to person. Just check what you usually need for an adventure and check if you would be able to improvise it.
You might want to have a look at the book Return of the Lazy Dungeon Master. This book contains a lot of info about preparing the right things for flexible games.
Use your time in the session
When the players decide their course if action in the same session, you need to use your time wisely. When the players decide to go see an NPC you did not prepare, you can come up with the important things while the players discuss the details of their plan.