Your query is "Also is there any law that states if one gets a government job all the terms between that person and the private company will get voided ?"
Unfortunately the answer seems to be NO.
The easiest way is apply your rapport, goodwill, with your immediate reporting authority, superiors, HR and your abilities/skills like, negotiating, persuasion, persistence and request them to help you and waive off the notice period and notice pay. Company can do it. You may submit a humble communication in writing to good offices of your appointing authority, MD/CEO, Chairman, Company Secretary, HR-Head with a copy to your reporting authority and appeal for waving the notice period/notice pay. They may grant waiver.
You should submit of notice of resignation in writing by letter thru registered post followed by email to your appointing authority, with effective date of resignation (as suitable to you. You may give notice and avoid abrupt termination) clearly written in it and request the good office to ensure completion of smooth exit formalities, and to supply you acknowledgment/acceptance of your notice, acceptance of resignation, work experience/service certificate, relieving certificate, form 16, PF accumulation reports, PF withdrawal/transfer forms, FNF statement, payment of your dues, and to take charge and issue you receipt of company property/charge within and up to effective date of resignation. You may mention the reason of your resignation and mention that you are willing to cooperate and train replacement employee designated as your replacement up to the effective date of resignation and company should inform you well in advance. Complete all tasks on hand, submit company property under acknowledgment, and submit a written communication that nothing is pending at your end.
Are you are under probation? if yes three months notice period during probation seems to be unreasonable.
What is your designation and nature of duties? You may yourself pay a visit to o/o labor commissioner and meet the ALC in person and they may confirm that 3 months notice period during probation is unreasonable and you can get some relief.