In the case of Federal Legislators, their immunity is written into the constitution explicitly.
No such explicit provision exists for government employees.