You can't just bolt two files together and expect them to magically work out how to reorganise themselves!
Video files are complex objects, with multiple streams inside - to join two videos, you need to append the video streams together, and append the audio stream together separately. What you have done is weld a car onto the front of your existing car and expect it to magically become a stretched limousine!
If you want to join videos, then look at VirtualDubMod - it's open source (it doesn't join files very well but you can get the source). I use
AviDemux[
^] when I want to - it's source isn't available, but it's free and does a pretty good job.