All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Prayers are of two kinds: obligatory prayers and voluntary prayers. The five daily prayers are obligatory; any prayers other than these are desirable, with a difference of opinion among the scholars regarding some prayers whether they are obligatory or desirable such as the prayer of salutation of the mosque, the Witr prayer and the two ‘Eed prayers. For more benefit on the types of prayers in general, please refer to Fataawa 83409 and 85588.
With regard to the prayers which you mentioned in the question, some of them are legislated and there is Sharee’ah-based evidence for them; however, some of them are not legislated as there is no Sharee’ah-based evidence for them. For instance, the two Rak’ahs after assuming the state of Ihraam are legislated as we have already clarified in Fataawa 112755 and 115788. Also, we have clarified in Fataawa 82384 and 84048, that the prayer for a need is legislated, and in Fatwa 88799 that the prayer after returning from travel is legislated.
Also, praying two Rak’ahs on the night of the consummation of the marriage with one's wife is legislated, as Ma’mar narrated from Al-Aa’mash from Abu Waa’il that a man came to Ibn Mas’ood and said: “I married (i.e. concluded my marriage contract to) a woman and I fear that she would hate me, so ‘Abdullaah Ibn Mas’ood said to him: “Mutual amity is (a gift) from Allaah, and dissension is from (caused by) the devil to make a person hate what is made lawful for him/her, so when she is brought to you, ask her to pray two Rak’ahs behind you.” [At-Tabaraani in Al-Mu’jam Al-Kabeer and Abdur-Razzaaq in Al-Musannaf] For more benefit, please refer to Fatwa 129441.
Praying two Rak’ahs when entering the house and when going out of it are also legislated as it is confirmed that the Prophet said: ''If you leave your home, pray two Rak’ahs to prevent you from the evil exit, and when you enter your home, pray two Rak’ahs to prevent you from the evil entry.” [Al-Bazzaar and Al-Bayhaqi in Shu’ab Al-Eemaan, and Al-Albaani classified it as Hasan (sound)]
Therefore, all the above prayers are legislated.
Likewise, it is legislated to perform two Rak’ahs before execution, as Abu Hurayrah said: “When Khubayb Ibn ‘Adiyy was taken by the disbelievers to be killed during the life time of the Prophet he said: “Let me pray two Rak’ahs”. Thus, he was the first person to have prayed two Rak’ahs before execution.” [Al-Bukhari and Muslim]
Concerning the two Rak’ahs after coming out of the place of Ghusl (bathroom), then if what is meant here is performing the legislated Ghusl after being in a state of sexual impurity or after menses, then they are legislated.
On the other hand, with regard to praying two Rak’ahs when the marriage contract is concluded or when leaving the Prophet’s mosque in Al-Madeenah, or when entering a land where Allaah has not been worshipped before, or when passing through a land that has not been travelled to before, or when leaving the place of washing (if washing is not with the intention of performing ritual purity); then we are not aware of any Sharee’ah-based evidence for these prayers. It is known that it is not permissible for a Muslim to worship Allaah with something that is not legislated in the Sharee’ah.
Allaah Knows best.