I have had that happen to me as well. In my case, it was the hood. I hadn't closed it completely, and the right front corner was not quite latched down tight. Click the hood latch, slam the hood again (gently!), and try to lock the car.
If it is a door, hood or hatch switch that is preventing the alarm from arming, you can tell by locking the doors from the inside switch before closing them. If the alarm turns on, then your fob is the problem. If not, then you have a door/hood/hatch closure switch which needs an adjustment.