El guardia and la guardia are both correct. One is a male guard and one is a female guard. Here is a case when the occupation looks to be one gender, but can be either, depending on the article that comes before it. Another example of when this happens is with "the journalist" -- it can be either "el periodista" or "la periodista", depending on if you are talking about a man or a woman. Also check out poeta, optometra, terapeuta, optimista, pesimista, artista, optometrista -- they all do the same thing.
It seems "el guardia" is a policeman or guardsman, whereas "la guadia" has at least 3 meanings:
1.) "the guard" like in "the civil guard" or the "Swiss guard"
2.) "the guard" like in "to be on guard"
3.) "the policewoman"
Does spain allow for female guards? ^^ And if so, how would you write that?