So... I'm trying to build a scenario that lasts for a long time (between 45-60 turns), but the player, which has a weird combination of multiple races, and the undead (computer) team always seem to end the battle at about 12 turns or so.

How could I balance the sides out better so that the teams should have to fight for a significant amount of time?

A lot of it probably comes down to the map. One way to make a fight take longer is to make the fighting area very narrow. This tends to be grueling and not very fun, but it takes longer. Another way is to have higher starting gold and map with multiple locations that offer high defense and good village access. Also, extra keeps help. The easier it is to hold ground and heal, the longer it takes to control an area. The real balancing act with designing a map to have a long battle is making it stay fun for that long. And the more hard areas to capture, narrow passageways, and tomato surprises there are, the harder it will be to motivate someone to see it through. Good luck.

The sides will have to recruit units a couple at a time. Setting up lines and preparing for attack will take longer, and reinforcements will arrive in a steady stream.

Another idea is to change the winning conditions. Instead of having to kill the enemy leader, maybe you need to kill a certain number of enemy units for example. The player would be forced to let the AI regroup and attack again until they reached the correct number. Or, you have to own every village on the map, and undead units pop out of each one. More come out each time until whole squadrons are coming out of each village.

You could also look at mainline scenarios that are particularly long and see how they did it. Northern Rebirth and Under the Burning Suns both have a 55 or 60-turn scenario.

Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

An idea to which I often fall back:
Having a higher level guardian, who prevents you from going into some area too early. Or in your case, who pushes back a side which is advancing to much.
The standard guardian which is often used (probably because Micro AIs were just added in 1.12) has the disadvantage that he goes farther and farther once he has been triggered, possibly up to your keep.

The return guardian MicroAI would be the one I mean. You take a higher level unit with high MP, such as the Chocobone for Undead.