Grammatically, both by and as are acceptable in either of the examples given. But as mathematical statements, both examples have problems.
In the first example, “The function f is defined by/as f=a+b+c”, unless a, b, c all are previously-defined functions or constants, the arguments of f and its dependence on them is unclear, ie undefined, hence the statement that “f is defined” is improper. Instead say (for example) “Let f(x) = a+b+c(x)” [in the case where a, b are constants and c(x) is a function].
In the second example, as is likely to be unacceptable to many mathematicians, and by, while acceptable, misleading. That is, the expression “x is defined as a = g(x)” would be viewed as nonsense, and “x is defined by a = g(x)” as an assertion that needs to be proved, rather than as a definition, because g⁻¹(a) might be undefined or might have multiple values. Instead say “Let x be such that a = g(x). To see that x is well-defined, consider ...”