Here's how to determine if a cat's anal glands need to be expressed:

Observe the area around the cat's anus. If there is redness and swelling around the anus, it may be anal gland inflammation, which requires anti-inflammatory treatment; if there is black or brown discharge around the anus, it may be due to excessive anal gland secretion, which needs to be cleaned.
Observe the cat's behavior. If the cat frequently rubs its bottom on the ground or licks its anus, it may have a problem with its anal glands and needs to be checked.
Normally, a cat's anal glands don't need to be expressed. Expression is only necessary when the anal glands are inflamed or secreting excessively. If a cat has diarrhea or soft stools due to gastrointestinal issues, the anal glands may not be stimulated or squeezed, potentially leading to difficulty in defecation. In this case, it's necessary to express the anal glands. If a cat's anal glands are red, swollen, itchy, or painful due to a bacterial infection, the cat may frequently lick its bottom, rub its bottom on the ground, and you may even see visible redness and swelling around the anus.