Thank you for reaching out.
A visa stamp in a passport is a travel document. The visa needs to be valid at the time you enter the U.S. Once you are granted permission to enter the U.S., it's your F-1 status that is your legal permission to be present in the U.S.
Based on your plans to return home and attend graduate school in 2024, you will need to end your F-1 status. To return to the U.S. in the future, you would work with your school to obtain a new (initial) I-20 that will have a new SEVIS ID number. We would recommend that you reapply for an F-1 visa at that time so that your SEVIS ID number matches on your visa and your I-20, however, that is a question you could consult with your school about in the future.