Localized solutions of the Dirac equation for an electron moving in free space and electromagnetic field lattices with periodic dependence on space-time coordinates (electromagnetic space-time crystals) are treated using the expansions in basis wave functions. The techniques for calculating these functions with any prescribed accuracy are presented. It is shown that in the crystals created by two counterpropagating plane electromagnetic waves with the same or the opposite circular polarizations, the Dirac equation describing the basis functions reduces to matrix ordinary differential equations. These functions and the corresponding mean values of velocity, momentum, energy, and spin operators are found for the both types of crystals. Localized solutions describing the families of orthonormal beams in electromagnetic space-time crystals and free space, defined by a given set of orthonormal complex scalar functions on a two-dimensional manifold, are obtained. By way of illustration the orthonormal beams in free space and various localized states with complex vortex structure of probability currents, defined by the spherical harmonics, are presented. The obtained solutions have high probability density only in very small core regions. The evolution of wave packets with one-dimensional localization in the both types of crystals created by two circularly polarized waves is described.