Actually there is a very big difference between a Prophet and a Messenger.
Heres the thing about your question, there is a difference between a Nabi (Prophet) and a Rasuul (Messenger) . Prophets are just people that are inspired by Allah, they preach the book of Allah etc etc but Messenger is a warner sent to a nation, if that nation accepts him then they will be saved and forgiven for all their sins and if they reject them , they will be destroyed for their sins so a Messenger can't fail or get killed but a Prophet can fail and killed (The Children of Israel used to kill prophets).
"Allah has decreed: "Verily! It is I and My Messengers who shall be the victorious." Verily, Allah is All-Powerful, All-Mighty." (Quran 58:21)
This is why Allah saved Jesus (AS), he was a messenger , those who rejected him were put down while those who accepted him were blessed.
" when Allah said, "O Jesus, indeed I will take you and raise you to Myself and purify you from those who disbelieve and make those who follow you superior to those who disbelieve until the Day of Resurrection. Then to Me is your return, and I will judge between you concerning that in which you used to differ." (Quran 3:55)
Though this was not the case with John the Baptist (AS), he was only a prophet and got killed as far as the Bible say.
Same thing goes for Muhammad (PBUH) , he couldn't be killed and those who followed him succeeded in this life and the next while those who reject truth were put down . This is the Law of Allah where He puts the judgment day on earth as an evidence to show that the real Judgment day is no joke.
"And for every nation is a messenger. So when their messenger comes, it will be judged between them in justice, and they will not be wronged" (Quran 10:47)
Prophet Noah,Moses,Lot,Hud and so on, were all messengers, their nations rejected them and Allah destroyed them for their sins.
as for the question about Mary (AS) . There are no prophetess in Islam, women are given the honor of being mothers and men are given the honor of being prophets.