What would cause a cat to attack after two years of no attacks ever?

It's impossible to say for sure without more information, but here are some possible reasons why a cat might suddenly become aggressive after two years of being peaceful:

Medical:

* Pain: Cats may become irritable and lash out when in pain. This could be due to a sudden injury, an underlying health condition, or even something like arthritis.

* Cognitive decline: Older cats can develop cognitive decline similar to dementia in humans. This can lead to confusion, disorientation, and aggression.

* Hormonal changes: Changes in hormone levels, especially in older cats, can affect their behavior, leading to increased aggression.

* Infections: Some infections can affect a cat's brain and behavior, leading to aggression.

Environmental:

* Changes in their environment: Major changes in their environment, like a new pet, a move, or even a change in furniture arrangement, can cause stress and aggression.

* Territorial issues: A new cat in the house, a visitor, or even a new piece of furniture could be perceived as a threat to their territory.

* Stress: Stress from a variety of sources, like over-grooming, loud noises, or lack of interaction, can also lead to aggression.

* Lack of outlets for energy: Cats need appropriate outlets for their energy. If they are bored or frustrated, they may become more aggressive.

Social:

* Changes in their social interactions: A cat that used to be the only pet might suddenly become aggressive if a new cat is introduced.

* Fear or anxiety: Cats can become fearful and aggressive if they are afraid of something or feel threatened.

Other:

* Changes in their diet: Some cats may become more aggressive if they are not eating a balanced diet.

* Medications: Certain medications can cause side effects, including aggression.

What to do:

If your cat suddenly becomes aggressive, it's important to consult your veterinarian. They can rule out any medical causes and help you develop a plan to address the behavior. You might also want to consider working with a certified animal behaviorist.

It's important to remember that cats can be complex creatures. Understanding their behavior and providing them with a safe, stable, and stimulating environment can go a long way in preventing and managing aggression.