https://plato.stanford.edu/entries/compatibilism/
The feeling of Free Will is bootstrapped from making decisions in a complex world. The subconscious makes most decisions automatically, based on left-brain exploitation of the current situation for survival. The timescales are too short for slow consideration to have an evolutionary advantage. Any imprinting of this instant behavior is made by stress hormones, which enhance memory retention for unusual or extreme situations.
However, the right brain is tasked with fitting actions into a wider context of long-term survival. It can run what-if scenarios, imagine different courses of action, and different outcomes. Its view of an action is always in the belief that something could be different next time, so something could be different last time - I could have done something else. But this is false, the left-brain was in control, and the right brain just provides post hoc rationalizations for those forced actions.
So, approximately, Free Will is the story the right brain tells itself after the left-brain already made the decision.
For more on the split brain aspect of this, see McGilchrist, The Master and His Emissary and The Matter With Things.