All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad
is His slave and Messenger.
You are required to sincerely repent to Allah the Almighty for this sin in a manner that fulfills all the conditions of repentance, which is to immediately stop committing the sin, to deeply regret having done it, and to make a firm and sincere determination never to return to it. Whenever you sin, repent sincerely, and do not despair of Allah’s mercy. Frequently supplicate to Allah that He protects your chastity and keeps you safe from these sins. Furthermore, you should keep the company of righteous women, constantly remember Allah the Almighty, and turn away from all the causes and paths that might expose you to committing this sin. Also, seek help by fasting frequently, and increase acts of obedience and good deeds that erase sins, because good deeds erase bad deeds. We ask Allah to grant us and you sincere repentance.
Lastly, the fact that your elder siblings are unmarried or that you are studying medicine should not prevent you from getting married to protect yourself. Explain your desire of marriage to your family if you are not afraid of any negative consequences.
Allah knows best.