A good democracy has various checks and balances between its political institutes to prevent the abuse of political power. In democracies that are also a Constitutional Monarchy, the Office of the Monarch is one of the political institutes that retains some political power. To ensure that a ruling Monarch doesn't abuse this power, some constitutions require a Monarch to consult the Legislature and / or the Executive. Marriage is often one such domain.
This is because historically, a royal could only marry another royalty and marriages to commoners was prohibited to them (unless they gave up their royal title). As royal suitors were often limited, and you don't want too much inbreeding in your Monarchical line, this meant that suitors often had to be considered from foreign royalty too.
Such kind of royal marriages, between royal families in different countries, were often also seen as an opportunity to create political alliances between 2 countries and / or also to improve diplomatic relations. Thus, it was often necessary for the government and the Parliament to get directly involved in the diplomatic negotiations of the marriage, which was essentially also very political in nature.
Another historic reason for getting the permission of the Legislature or the Executive for a Royal Marriage, has to do with the local politics itself. The Office of the Monarch being a political institute, the Monarch and their spouse, and their actions, all have a lot of political symbolism associated with it. Thus, for political stability, it was considered important to show that the government and the Monarch weren't in opposition on any major political issues. For example, when slavery of the coloured people was common, a Monarch marrying a person of colour would send very confusing messages to the public (as one of the reason often cited for slavery was that the white man was superior to a person of colour), and some politicians would consider it a political affront to their beliefs. This is also why royalties couldn't marry divorcees, as divorced men and women were considered lower in standing, and conservatives governments politically endorsed such ideas.