Gap years do not usually create problems in government jobs, because the main eligibility factors are age limit and educational qualification. Most government recruitment (UPSC, SSC, Banking, Railways, State Services, etc.) accepts candidates with study or career breaks. Written exams are not affected at all.
At the interview stage, the panel may ask about the gap years, so you should be ready with a simple and honest explanation (such as exam preparation, higher studies, personal reasons, health issues, or family responsibilities). As long as your reason is clear and genuine, it will not hurt your chances.
Background verification in government jobs mainly checks certificates and identity; continuous employment or education history is not strictly required. Many aspirants take gap years solely to prepare for competitive exams, and it is generally understood.
In short, Gap years are acceptable and do not disqualify you from government jobs — just ensure you meet the age criteria and keep a valid explanation ready.