The trouble is...
Mem is an MS-DOS program. It seems clear from the output you posted that you were running Win2K/XP/Vista command prompt (which is not MS-DOS).
The practical consequences of this are that, to cut a long story short, you are not seeing the total RAM installed, you are seeing the amount of contiguous extended memory which Windows has allocated to an MS-DOS virtual machine, which is a standard amount, namely 1 megabyte. That is what 1048576 bytes is. Hadn't you noticed that?
If you are running a batch file under Win2K/XP/Vista, you might as well not bother checking, because the answer is always going to be 1048576 bytes.
if you want to know the total amount of physical RAM installed on the motherboard (why?) you will have to use another command, such as systeminfo.
If you are using genuine MS-DOS then a complete rethink will be necessary. You cannot use NT command prompt techniques in MS-DOS. You need to state what OS you intend using.