For study starting in Fall of 2023, you should start now if you haven't already. In other words, give it a year or so prior to your intended start date. Due dates for US institutions might be as early as early December of this year, others a few months later.
How long it takes to write letters is dependent on you and your other tasks, but don't expect that a first draft of a Statement of Purpose is a good draft. Have someone look at it and comment on it. The other documents are similar. So a document might take a couple of weeks to prepare, but you can also write them in parallel. Rewrite as you would for any important document.
For a person not a native English speaker, get some advice on your writing.
Take any required exams like the GRE sometime in your last undergraduate year if you are pretty confident of doing well. Perhaps earlier otherwise. That is, in the year before you expect to start.
Talk to potential letter writers early. Let them know of your plans and get their advice. Let them know that you might ask them for a letter so they can be thinking about it. Don't make it a last minute request. A month or more might be needed.
Note, however, that most of these things occur in parallel, so it isn't as if you can add up the times to get a total. Expect considerable effort and be sure you meet the (perhaps variable) deadlines for the places you wish to apply.
Give yourself some time to investigate those institutions and choose a set of places, preferably not all with similar characteristics. For example, don't expect to be successful if you choose the top five programs in the US, as rejection by one is likely about the same for the others.
Most US programs don't require that you have an advisor selected (and accepted) to apply. Most students start with a bachelors only and advisor selection, along with choosing a specialty and topic, is a long way off. Starting with a masters shortens the time frame somewhat, but not as much as you might think, since comprehensives still need to be passed. A few lab sciences (for example) might require an advisor to be chosen to arrange funding, but most funding is via the department, not the advisor. But, you want to know that the institution you apply to has a few faculty in a topic you might be interested in.