There are two reasons why BART doesn’t run all night. The first is that BART like most other rail systems does its maintenance work on the rails in the wee hours of the morning. The second reason is that it is expensive to provide this service when there aren’t a lot of riders who ride during that time. This piece in the East Bay Business Times explains more.
There is now an all-night bus service that serves most BART stations in Alameda, Contra Costa, San Francisco and San Mateo counties so that you won’t be completely stranded if you miss the last BART train. Details are available here.