Free fermions on a three-dimensional lattice and tetrahedron equations