Apostasy in Islam comes under Sharia, some of the laws remain the same regardless of changing circumstances and other change with them. Most of it is up to individual Muslims to follow in their own lives. Some are for judges to implement in courts. The third category is a set of laws that are implemented by the ruler/political authority based on the best interest of society, apostasy fall under the last category.In the past it was implemented to protect the integrity of the Muslim community. The Arabic noun ridda and the verb engaging in it were understood not as meaning a personal choice of changing one’s religion but as the public act of political secession from the Muslim community.
Dr. Jonathan Brown an Associate Professor and Chair of Islamic Civilisation at Georgetown University wrote a research paper on apostasy and here are some of the things he mentioned. I wanted to summarise the research paper, but I can't explain it as good as he can. I'll post the link below so that you can read the views on apostasy within Islam and the differences among Islamic scholars.
'' The notion that the crime of apostasy in Islam was more a matter of protecting a state and social order than of policing individual beliefs was
articulated in the 1940s by the South Asian Muslim activist intellectual Abul Ala Mawdudi (d. 1979). Modern scholars such as the Egyptians Maḥmūd Shaltūt (Shaykh al-Azhar, d. 1964) and Yūsuf al-Qaraḍāwī, as well as the late Iraqi-American scholar Ṭāhā Jābir al-ʿAlwānī (d. 2016), have reconsidered how apostasy should be viewed in contexts in which religious identity is not a state matter.
[42] They have concluded that what was criminal about apostasy was its public dimension and the threat it posed to a public order built on confessional identity. It is this public element, they argue, not the question of a person’s private decision to follow their conscience in changing their religion, that Islamic law should focus on''.
Jonathan Brown also mentions
'' The way that the early Muslim community seems to have understood apostasy differs strikingly from the decisive rulings of the later schools of law. This is most clear in the rulings of the Prophet ﷺ himself. There is no reliable evidence that the Prophet ﷺ ever executed anyone for apostasy, as was observed by the famous scholar of Cordoba, Ibn al-Ṭallāʿ (d. 1103).
[30] When one of the Companions, ʿUbaydallāh bin Jaḥsh left Islam and became Christian while the Muslims were seeking refuge in Ethiopia, the Prophet ﷺ did not order him punished.
[31] The Treaty of Ḥudaybiyya, which the Prophet ﷺ concluded with the Quraysh, stated that if anyone decided to leave the Muslim community in Medina no harm would befall them. There was no mention of a punishment for apostasy. In fact, when a man who had come to the Prophet ﷺ just the day before to pledge his loyalty to Islam wanted to be released from his oath, the Prophet ﷺ let him go.
[32] Imam al-Shāfiʿī himself notes how, during the Prophet ﷺ’s time in Medina, “Some people believed and then apostatized. Then they again took on the outer trappings of faith. But the Messenger of God did not kill them.''
https://yaqeeninstitute.org/jonathan-brown/the-issue-of-apostasy-in-islam/