In a Parliamentary Democracy, you don’t vote for the leader directly, you vote for the Party (via choosing your local MP). The Party with the most MPs elected forms the government; that Party’s leader then becomes the PM.
The Tories have a majority in the UK Parliament, so they’re currently running things. If their leader loses the support of the Tory caucus (i.e., all the MPs), THEY can get rid of that leader and choose a new one, without a national election being called (because they still have their majority in Parliament, nothing’s changed there).
The caucus can get rid of their leader by either asking that person to resign voluntarily, or they can give them the boot by holding a caucus vote. In this case, May chose the first route rather than be kicked out.
Thanks.