A couple weeks before, I bought a custom 3D printer that has an Ultimaker 2 motherboard in it. However, the dimensions of the printer is not same with Ultimaker 2 (X and Y same, a bit smaller on Z). The printer had tinkerfirmware installed in it. Today, I tried to print a premade .gcode file (Which was for another 3D printer I guess) and after pressing print, The machine told me the file will overwrite machine settings, and I pressed yes for it. After that, the dimensions of my 3D printer has changed in it's firmware. The bed is raising more than it should while starting calibrating, and not setting it's position precisely. (To make the 1mm gap, I had to move the bed down 4-5mm away from where it should be.) Now the question is, what can I do to fix this problem ? I also tried reinstalling original firmware which didn't really worked. (All the parts are orginal except the frame, which is a bit more smaller on height) How should I measure the height of printing area?
Your printer is an Ultimaker clone or something else? All of the original firmwares located on TinkerGnome's Github are configured for Ultimaker printers so if you are using them on something different you will need to configure it before using it. The easiest option would be editing this print file that changed your settings to your desired settings and then reloading it.
How to find your actual Z? Well that's a bit difficult without more information. I'm guessing from your description that your printer homes at Z max? If it's homing at Z max you need to home the machine, jog the Z axis to where you want 0 to be (usually using a piece of paper between the nozzle and bed), then record the Z axis position and enter that as your travel limit in the firmware. If your printer homes at Z min this could be as simple as changing the homing offset.
Firmware is stored in EEPROM, and may contain some default values, but does not affect the calibration values which are stored in EEPROM.
You should be able to reset the calibration to 'factory defaults', this actually means to take the defaults in the firmware and store them in EEPROM.
M502 to load firmware defaults into the current session.
M500 to write the settings from the current session into EEPROM.
It is unusual for a design in gcode to include modifications to the settings, but maybe it was done to change acceleration or something similar.