Cats spray by squirting urine backward onto a vertical surface (source). Both male and female cats can do this. They tend to do this as a territory marking behavior or when they have an urge to mate (source). If your cat hasn’t been spayed or neutered, then you can expect this behavior to emerge at some point.
However, cats also spray when there are other cats nearby — they can feel threatened. They might spray when they’re ill, stressed, or there is a new routine in the home. If you’re worried, contact your vet.