They get attacked as soon as they enter the map.
There are probably too many undead on the surface of your map, as caravan guards should be able to punch their way through smaller common undead wildlife. You should build weapon traps in a trap hallway or other defense that will mulch the undead for you as they attempt to reach the majority of your citizens. Automating the process is advised since military dwarves should be reserved for fighting trap-avoiding monsters or overwhelmingly large sieges.
The ideal solution would be to force the wagons to spawn at a location of my choice close to my fort's entrance. My attempts to do this have failed. Is there a workable solution?
As stated on the wiki page for the Trade Depot, any location where the depot accessibility indicator shows wagon access, the game can spawn a wagon. What the wiki does not say is that any location which is "not wagon accessible" but also not completely blocked, is still capable of spawning pack animal traders. This results in a scenario where the wagon can spawn only at the available spot but the pack animals spawn at their intended location; walking the entire map surface with slow animals. If the task is to absolutely block all trader spawning anywhere you do not want them to be, there are very few options available:
The most reliable method and the one you should attempt in blocking the map edge, is with placement of the thinnest possible raising bridges
on the map edge, raising towards the map edge. Once raised, bridges form a wall that completely blocks pathing, sight and spawning. Just keep in mind that by blocking the map edge, you're now forcing all ground-based spawns to appear on the remaining unblocked tiles; using your military may be required to clear any undead prior to the caravan arriving.
If the goal though is only to block the wagons from spawning, you can very quickly dig a simple pattern of trenches to block them from spawning where you don't want them:
..........
V..V..V..V
.. .. ..
---------- UNDIGGABLE MAP EDGE
Period is ground, V is down ramp, space is rampless ground 1z-level below.
Keep in mind that the reason this works in blocking wagons is the rampless 1z-level cliff the trench creates. You can absolutely dig an entire map-spanning continuous trench (remember, that has no ramps in it on the map edge side) that forces all spawns to walk around to the nearest bridge; but it could take a great deal of time depending on the number of miners you have. (and more dwarves on the surface means more risk for attack by undead... or more dwarves lost to an "fog of evil" event) By putting spaces in the design you allow full pathing for non-wagon units and make the job much faster. You can even revisit the trench later and extend it to a full border trench if things get too dangerous.
In evil biomes people usually put Trade Depot in caves. Evil biomes are only on surface?
Evil biomes extend all the way down into the caverns, which includes any kind of undead-raising biome effect. Trade caravans only spawn on the surface, but can also be allowed to exit the map through the caverns; surface entries are required, surface
exits are not.