Rabbi Aron Moss quotes the Midrash Vayikra Rabbah (5:5) suggesting that one should buy a burial plot when still alive. If that is the case, why didn't Avraham buy the cave from Ephron for Sarah (and him) earlier (Bereishis 23:7-19)?
The medrash says that one should purchase a plot (approximately) in a cemetery so that one should merit being buried in that cemetery.
This assumes that you have an operating community with a fixed cemetery.
In the case of Avraham that was not true, he invented the community. So it would not have been possible for him to assure himself of a place in a communal cemetery by buying into it, because he was the community.
The simple answer why he did not pursue Ephron sooner was because he didn't want to attract attention to the fact that it was a special, spiritual place. Had Ephron known that it was something special he never would have sold it.
It writes in the Zohar 1:127b:
וְאִי תֵימָא אִי הָכִי אַמַּאי לָא בָעָא לָהּ עַד הַשְׁתָּא, בְּגִין דְּלָא יִשְׁגְּחוּן עֲלֵיהּ הוֹאִיל וְלָא אִצְטְרִיךְ לֵיהּ. הַשְׁתָּא דְּאִצְטְרִיךְ לֵיהּ, אָמַר, הָא שַׁעְתָּא לְמִתְבַּע לֵיהּ. תָּא חֲזֵי, אִי עֶפְרוֹן הֲוָה חָמֵי בִּמְעַרְתָּא מַה דְּהֲוָה חָמֵי אַבְרָהָם בָּהּ, לָא יַזְבִּין לָהּ לְעָלְמִין. אֶלָּא וַדַּאי לָא חָמָא בָהּ וְלא כְלוּם, דְּהָא לֵית מִלָּה אִתְגַּלְּיָא אֶלָּא לְמָארִיהּ, וּבְגִין כָּךְ לְאַבְרָהָם אִתְגַּלְּיָיא וְלָא לְעֶפְרוֹן. לְאַבְרָהָם אִתְגַלְּיָיא דִּילֵיהּ הֲוָה
And if you want to say, why did he not seek to buy it until then? Because he had no need for it, he was afraid that they would check it. Now that he needed it, the time had come to ask for it. Come and see, If Efron had seen in the cave what Abraham saw, he would never have sold it. But because Efron saw nothing in it, as nothing is revealed except to its owner, it was revealed to Abraham only and not to Efron. It was revealed to Abraham because it was.
This is why Avraham therefore bade his time as he realised he had to play a bit of a game with Ephron.1 He did not ask for it outright as he didn't want to draw too much attention to his interest. The Zohar 1:127a writes earlier:
תָּא חֲזֵי, הַשְׁתָּא אַבְרָהָם בְּחָכְמְתָא עֲבַד בְּזִמְנָא דְּתָבַע קִבְרָא לְשָׂרָה, דְּהָא כַּד תָּבַע לָא תָבַע לִמְעַרְתָּא בְּהַהוּא זִמְנָא, וְלָא אָמַר דְּבָעֵי לְאִתְפָּרְשָׁא מִנַּיְיהוּ. אֶלָּא אָמַר, תְּנוּ לִי אֲחוּזַת קֶבֶר עִמָּכֶם וְאֶקְבְּרָה מֵתִי מִלְּפָנַי. וְאִי תֵימָא דְלָא הֲוָה עֶפְרוֹן תַּמָּן. תַּמָּן הֲוָה, דִּכְתִיב וְעֶפְרוֹן יוֹשֵׁב בְּתוֹךְ בְּנֵי חֵת, וְאַבְרָהָם לָא אָמַר לֵיהּ בְּהַהִיא שַׁעְתָּא כְּלוּם.
Come and see, Avraham behaved wisely when he asks for a grave for Sarah, for he did not ask for the cave immediately or say that he wanted to be separated from them. Instead, he said, "Give me a possession of a burying place with you, that I may bury my dead out of my sight" (Bereishis 23:4). If you say that Ephron was not there, he was present, as it is written, "And Ephron dwelt among the children of Chet" (Bereishis 23:10). Abraham said nothing to him for the time being.
1 It is worth noting that he only discovered the cave when one of his calves ran off - refer to Bereishis 18:7 where it says, "וְאֶל־הַבָּקָ֖ר רָ֣ץ אַבְרָהָ֑ם" - "And Avraham ran to the herd". The commentaries explain that upon following this calf it ran to Chevron where he discovered the Ma'aras HaMachpeilah - See the Paneach Raza, Midrash Aggadah, Pirkei DeRabbi Eliezer 36 and Zohar 1:127b - So it would be fair to say that additionally, Avraham only found out about it relatively late on and upon entering for the first time he realised that it was the right site in which to be buried (Zohar 1:128a)