Cats are territorial. When a cat rubs against you it is marking you as belonging to them. A cat may use the feline spray method to mark out their territory. This is unfortunately where they spray their urine on different places to identify their domain. Not a very good practice for inside your home. Sometimes this might relate to a stressful situation they have been through. It could be about moving house. It could happen as a result of the activity of another cat outside the house. It is not always easy to identify what the problem is that has caused the cat to respond.