Brain infections such as meningitis and encephalitis can inflame and damage brain tissue. This swelling irritates nerve cells and disrupts the brain’s normal electrical signals, which can trigger seizures. In some cases, the infection leaves scar tissue that continues to interfere with signal flow even after recovery, increasing the risk of developing epilepsy later.