Yes, Male and Female pokemon can learn Attract. The only pokemon that can't learn Attract are the genderless pokemon like unown.
Any pokemon that has a genger can learn attract. If a female learns it it works on males. If males learn it it works on females. Pokemon that are gengerless like Porygon cant learn it.