In this study, a conductive double network cross-linked hydrogel with anti-swelling and shape memory was successfully prepared by [2-(methacryloyloxy)ethyl]dimethyl-(3-sulfopropyl)ammonium hydroxide (SBMA), polyvinyl alcohol (PVA), and tannic acid (TA). The hydrogel is formed by SBMA radical polymerization to form the first layer of the network and PVA freeze-thawing to form the second layer of the network. The conversion of -SO3- on the SBMA structure to -SO3H in the presence of TA and the electrostatic repulsion between -N+(CH3)3 reduces the osmotic pressure and achieves an anti-swelling effect. The prepared hydrogels have good mechanical properties tensile strength of 1.4 MPa, elongation at break of 287.52 %, and compressive strength of 2.36 MPa at 80 % strain. The structure of SBMA forms ion channels with stable conductivity, simulating the realization of underwater monitoring movements. In addition, the hydrogel can recover its original shape in a few seconds at 60 °C and has a 99 % inactivation rate against E. coli and S. aureus within 24 h, which can provide new ideas for the biomedical field.