Why don't semi-automatic modes on a DSLR take flash into account when calculating exposure?
They do. But when using Aperture Priority exposure mode with flash in low light situations, the camera usually assumes the photographer wishes to use a technique called 'slow shutter sync' or 'dragging the shutter'. When using Av mode with TTL flash for brightly lit scenes the camera usually assumes the photographer wishes to use the flash for "fill."
Before we can understand what happens during TTL flash metering, we must first understand how metering works in general. There is no single "correct" exposure value for an entire scene, there are only correct exposure values for objects with a specific luminance value within that scene. If "correct" exposure is equivalent to 18% gray, then only one luminance value in a scene can be rendered at that level. Everything brighter than the object rendered 18% gray will be closer to saturation, everything darker will be closer to black. Many scenes include differences in brightness that are greater than a camera's ability to record. Either some of the scene will be pure white, some of it will be pure black, or maybe even some of both.
When we choose a simple metering mode, we are telling the camera what part of the scene we are most concerned with exposing properly or we are telling the camera to expose for the areas halfway between the darkest and brightest parts of the scene. With more sophisticated metering modes we are telling the camera to compare the scene to a database in the camera and apply the proper settings to the scene based on which preloaded scenario our current scene most closely matches.
Here's where adding flash can get confusing: the flash will not raise everything in the scene in terms of 'stops' by the same amount. Consider two scenarios:
Fill flash. If a scene has 5 stops of contrast between the darkest and brightest parts of the scene, that means the brightest parts are reflecting 32 times as much light per cm² as the darkest parts (2^5=32). Assume all objects are roughly the same distance from the flash and the camera. If we add enough light to quadruple the amount of light reflected by the objects in the shadows (4x the light = two stops), we only increase the amount of light from the highlights by 1/8 (4/32) which winds up about 1/6 (8/√2=5.65) of a stop. That is half the smallest adjustment to exposure you can make by changing the aperture or shutter speed of your camera! What we accomplished was bringing the shadows two stops closer to the same brightness as the highlights without adding any significant light to the highlights. Think of it this way: if you have two buckets the same size and one has 1" of water in it and the other has 32" inches of water in it and you add 3" of water to both buckets the first bucket now contains four times as much water as it had before but the other bucket only has 1.09x as much water as before.
Slow Sync. If a dark subject is fairly close to the camera/flash, but the background is lit by ambient light, the camera meters for the background to set shutter speed and/or aperture and then adds enough flash to properly expose the subject in the foreground. Since the power of a flash is 1/4 as much for each doubling of distance the flash raises the brightness in the foreground much more than it raises the brightness of the background. And if the background is brighter to begin with than the subject in the foreground then the difference in the effect of the flash will be even greater because not only is the background receiving less of the flash's light per cm², but the flash's light the camera is receiving from the background is a lower percentage of the total light to the camera from the background.
So now the question is, "How does the camera tell each situation apart?" The answer to that is also twofold: It depends on the way the camera has been programmed and on the settings you have selected. Different camera makers design their TTL flash logic systems differently. And within a particular camera model the settings you choose tell the camera how you want it to act under different scenarios. Most recent TTL systems use the AF distance information reported by the lens and the focus point selected in the viewfinder to determine which area of the frame includes the subject. In general the brighter the scene the more likely the camera will try to provide fill flash and the darker the scene the more likely the camera will attempt proper exposure of the subject using the flash as the primary light source and then expose the rest of the scene as well as it can.
My Canon 5D Mark II, for instance, will assume I want to use slow sync when I am in Av mode and will allow for shutter speeds as long as 30 seconds to properly expose the background in low light situations (I can modify that to 1/60 second or even to 1/200 second via custom functions). On the other hand, if I am in P mode it will use a shutter speed of 1/60 second at the slowest and use enough flash to properly expose the subject at that Tv. It will adjust the aperture to try and properly expose the rest of the scene, but if the widest aperture and 1/60 second is not enough the background will still be dark. Likewise, if the background is much brighter than the subject it will use full flash power and attempt to reduce the exposure as much as it can with a smaller aperture and/or a faster shutter speed up to the camera's flash sync speed.
For more, please see:
What exactly does TTL flash sets its power to?
Why is flash TTL metering independent from ambient light metering?
How do TTL flash metering systems calculate how much power is needed?
How do I get my Canon 60D to use short shutter speeds with flash in Av mode?
Canon 600D Exposure Lock and Flash Exposure Lock
Why is my Metz 58 AF-2 using long shutter values when my Canon 60D is in Av mode?
What is this shadow in my photo?
Taking a skyline photo with a person closer to the camera during night time
What is "Dragging the Shutter"?