Merging video files is a bit like human surgery. In order to transplant organs, the tissue types, blood types, and other factors must match, or the body rejects the organs as an invading foreign body. In a similar fashion, the codec/format, container/wrappy, bitrates, resolution, frame rates, and some other factors must all match. You can no more randomly merge video files than you can transplant a heart from a dog into a person.
More often, videos have to be converted to a uniform format. The conversion tool of choice is determined by the input and the desired output.
Avidemux (freeware) is one good starting place for re-encoding video, but there are others. Without further information, there's not too much more that I can say.
Hope that helps.