I'm about to apply for a student visa to do my PhD (which will last 5 years). In the application site it says it's required for my passport to be valid during my period of stay, something impossible in my case as passports in my country last 5 years and I recently renewed it. My current passport will last until April 2024, how will this affect my visa application/issuing?
There are several issues here. Let's consider how passport validity, visa validity, and length of stay interact with each other.
Can US visa validity outlast passport validity? Definitely. An unexpired US visa in an expired passport can be used in combination with a new passport of the same type from the same country, without getting a visa in the new passport.
Can length of stay outlast visa validity? Definitely. US visas are solely for entry to the US, and the visa's expiration date just means the last day on which the visa can be used to enter the US. How long the person is admitted for is determined by the immigration officer at entry based on the regulations of the status the person is entering on, and is not affected in any way by how much validity is left on the visa. It is very normal to be admitted for months or years beyond the visa's expiration.
Can length of stay outlast passport validity? This is more complicated. There is a rule that one's passport must be valid for 6 months beyond the period of stay (or, for passports from countries in the "6-month club", the passport must be valid until the end of the period of stay). What this means in practice is that if the immigration officer is admitting you until a specific date on your I-94, that the date will be no later than 6 months before your passport expires (or, for passports from countries in the "6-month club", the date will be no later than the date your passport expires). If the length of stay on your I-94 was limited to a shorter time than you need due to the passport expiry, what you would normally need to do is, once you renew your passport, you apply for Extension of Status in the US or you leave the US and re-enter on your new passport (and your length of stay for the new entry won't be limited since your new passport is valid for a long time).
However, F students and J exchange visitors are almost always admitted for "D/S", which means you are admitted indefinitely, not until a specific date. In this case, that means your period of stay is not limited by your passport expiration (as long as the passport is valid for at least 6 months (or, for passports from countries in the "6-month club", valid for any length of time) at the time of entry). Someone admitted for "D/S" never needs to apply for Extension of Status, since they remain in status indefinitely as long as they comply with the conditions of their status.
It won't. They'll give you a visa for the entire duration of your study in the US. When your passport is about to expire, you can contact the consulate of your home country applicable to the US and get a new passport. I currently have a B1/B2 US visa which is valid beyond the expiry date on my passport.