I am completing my masters in a few months, and going for a job. I want to pursue my doctorate after 3-4 years of working. Is it better to speak with professors now, if they want to be my guide once I come back? Or better to reach them when I finally decide to come back to the university and start preparing for the entrance exam for Ph.D. ? (That is a few years from now).
Even if you don't want to work with them in the future, or change your mind one way or another, it is good to reach out while you still have an active connection to them. If nothing else, you will want letters of recommendation from them and it is all too easy for a professor to lose track of you over a few years. They have other students they are more actively thinking about after even a couple of years.
If you speak to them (preferable to writing) you can also ask what you might do in the interim to increase your chances of success in a doctoral program.
Note that in some places a professor might have little to say about graduate admissions (US, in particular, where it is a committee decision). But you still want to prepare them for a future ask. A wise professor will keep some notes about you, or even preemptively write a LoR and file it for future use so they don't forget details that might help.
I've been in that situation as a professor and had to ask the student to remind me of a few interactions we had to jog my memory.
No one, of course, will agree now to admit you in 3-4 years as things will likely change. They might not even be around then for various reasons.
No harm in engaging with your current supervisor about this as you have that connection already. They may also provide advice about things you can keep in mind while working, and what to do when ready to start your PhD. So for that reason, I'd recommend talking with them now than after 3-4 years working without contact.