Effective actions from block diagonalization in lattice gauge theories