Why does ester hydrolysis occur in basic medium
In basic medium, there is a huge amount of $\ce{OH-}$ and they will deprotonate the carboxylic acid as soon as it forms.
$$\ce{RCOOR' + OH- &lt;=&gt; RCOOH + R'O-}$$
$$\ce{R'O- + H2O &lt;=&gt; R'OH + OH-}$$
$$\ce{RCOOH + OH- -&gt; RCOO- + H2O}$$
The last deprotonation step is almost irreversible and consumes the base. This is why, an excess of base is usually added for ester hydrolysis.
The $\ce{RCOO-}$ is a negative ion, so it repels any nucleophile that comes close to it, so nucleophilic attack cannot happen, and the reverse reaction is prevented (as Maurice has mentioned in the comments). In essence it is this last step that drives the reaction to the product side.