  Stabilizer codes are a powerful method for implementing fault-tolerant
quantum memory and in the case of topological codes, they form useful models
for topological phases of matter. In this paper, we discuss the theory of
stabilizer codes as a discrete version of a linear gauge structure, a concept
we introduce here. A linear gauge structure captures all the familiar
ingredients of $U(1)$ gauge theory including a generalization of charge
conservation, Maxwell equations and topological terms. Using this connection,
we prove some important results for stabilizer codes which can be used to
characterize their error-correction properties. However, this perspective does
not depend on any particular Hamiltonian or Lagrangian, which as a consequence
is agnostic to the source of the gauge redundancy. Based upon the connection to
stabilizer codes, we view the source of the gauge redundancy as an ambiguity in
the tensor product structure of the Hilbert space. That is, the gauge provides
a set of equivalent but arbitrary ways to factorize the Hilbert space. We apply
this formalism to the $d=2$ and $3$ toric code as well as the paradigm fracton
models, X-Cube and Haah's cubic code. From this perspective, we are able to map
all these models to some continuum version which captures all or some of the
fractonic and topological features of their parent discrete models.
