I am thinking of a scenario in which a tunnel linking Hungary to Morocco is built around the 1500s by the King of Hungary in an attempt to colonize Morocco to get a border with the Atlantic ocean. What I am asking for is, could it be feasible in real life?
Only with magical assistance.
The shortest possible great-circle route from Hungary to Morocco is 2040km (1260mi).
An average reasonably-fit adult human can march about 35km each day on a long journey. Since we're assuming a roadway in this tunnel, let's be charitable and bump this up to 45km each day for each of the 45 days it will take them to traverse the tunnel.
In other words, each person traversing the tunnel must carry 45 days' supply of food, water, storage for their bodily wastes (they cannot leave it in the tunnel -- that would be disgusting!), and a source of light that won't asphyxiate them.
Let's see how much water that is: 4 liters per day means about 180 liters of water. For the average person in the 1500s, that's over three times their body weight. Of just water. That they must slog 45km every day. For a month and a half. And the weight doesn't decrease by too much, since they must carry their wastes back out of the tunnel!
Let's say folks get clever and pile their food and water on an oxcart. Same problem: The oxen need fodder and water too, and their cart cannot carry a 45-day supply for themselves, let alone any cargo.
So finally one of the King's advisers turns it into a rocket problem: Every couple hundred kilometers, the tunnel is widened into a tremendous supply depot. An army of oxcarts hauls cargo to the nearest (and hauls out the waste!), a smaller army forwards to the next, and so on, until a single colonist can stumble out the African end, barely alive and smelling utterly foul. If you do the math, you will conclude that the entire population (and all the oxen) of Hungary are inadequate to this task.
But it's all academic anyway. They don't have a source of light that does not involve combusting oxygen, so the miners building the tunnel will keep mysteriously dying of asphyxiation while still under their first mountain of the Alps.
Nah, it was more feasible to build two tunnels...
Another answer explains well why the Hungarians built two tunnels. One starts from a river at the surface and slopes ever downward, and one is very deep and slopes ever upward. The design allows water to fall from the high tunnel to the low tunnel at a vertical tunnel near the site of active excavation. These vertical tunnels are blocked off and replaced further on every year or so as the miners move out of range. The falling water turns the shaft of a primitive machine that bores out the rock, and men slide it onto rafts that they send out on the waters of the low tunnel. A constant stream of rafts arrives in the upper tunnel loaded with things for the workers and overseers: food, clothes, drill bits, opium, drabs ... everything a productive underground colony needs. But I hope you didn't need to finish your project by 2022. :)
The less said of the massive ever-turning slave-driven shaft that lifts all that excrement-laden transport water and sledges of excavated stone and garbage back up out of the abyss, the better. :)