Frege is the founder of a program called logicism that aimed to reduce all of mathematics to logic. In order to reduce mathematics to logic Frege had to expand what is meant by logic. Before him Locke, Kant and others understood by logic only Aristotle's syllogistic, which is a manipulation of simple implications (syllogisms). Frege's Logic went much further, and encompassed all of arithmetic in particular, if not all of set theory. But derivable from logic alone is what all three meant by "analytic". Under logicism all of mathematics would be analytic, including much of what Kant called "synthetic a priori" (but not the parts related to geometry and physics). So both Locke and Frege were right, they just meant different things by "analytic".
"Frege's conception of the analytic was suitably broader than Kant's. Kant required that conceptual containments be evident within the sentence, rather than that the sentence be displayed as a conclusion following logically from axioms whose own logical or conceptual truth was self-evident, and which might contain expressions not occurring in the sentence in question... Kant did not regard ‘7 + 5 = 12’ as an analytic truth. The Fregean, by contrast, is able to exploit the internal structure of the numerals, and to invoke the recursion axioms for addition (which themselves would have to have been derived in logicist fashion). So, for the Fregean, even if not for Kant, ‘7 + 5 = 12’ is an analytic truth."
The best attempt to realize the logicism program was Russell and Whitehead's book Principia Mathematica. However, after Gödel's results on incompleteness the program came to be viewed as a dead end, and was largely abandoned. Later, Quine argued convincingly that the analytic/synthetic distinction itself, even in a revised form adopted by logical positivists, can not be maintained at all. According to Quine, all knowledge, including the laws of logic, is synthetic, and ultimately empirical, this dealt a further blow to logicism. Although it is no longer believed that "all of mathematics" reduces to logic, the modern mathematical logic is much closer to Frege's conception of logic than to Kant's or Locke's.