If $n\in \mathbb N$ has binary expansion $n=\sum_{k\in S}2^k$ for a finite subset $S\subset \mathbb N$, then
$$ \sum_{j=0}^n\Big[\big( {n \atop j}\big)\text{mod}\, 2 \Big]x^jy^{n-j}=\prod_{k\in S} (x^{2^k}+y^{2^k})$$
More generally, but not needed here (see below): for sums of $r$ indeterminates $x_i$, the binary coefficient homogeneous polynomial obtained as expansion of $\Big( \sum_{i=1}^r x_i\Big)^n$ with coefficients reduced $\text{mod}\,2$ has the factorisation (in $\mathbb Z[x_1,\dots,x_r]$)
$$ \sum_{\alpha\in\mathbb N^r,\, |\alpha|=n}\Big[\big( {n \atop \alpha }\big)\text{mod}\,2 \Big]x^\alpha=\prod_{k\in S} \sum_{i=1}^r x_i^{2^k}. $$
In particular (for $x=1$ and $y=m$) by definition of $f$ and $g$, this implies immediately the relation $a(n)=(1+m^{2^f})a(g(n))$, just because $f\in S$ and $\{2^k\}_{ k\in S\setminus\{f\}}$ are the powers of the binary expansion of $n-2^f$.
Details on the above factorization: immediately by induction on $k$ we have $$\Big( \sum_{i=1}^r x_i\Big)^{2^k}= \sum_{i=1}^r x_i^{2^k}\text{mod}\,2.$$ Then,
from $n=\sum_{k\in S}2^k$ one has
$$\Big( \sum_{i=1}^r x_i\Big)^n=\Big( \sum_{i=1}^r x_i\Big)^{\sum_{k\in S}2^k}= \prod_{k\in S} \Big( \sum_{i=1}^r x_i\Big)^{2^k} = \prod_{k\in S} \Big( \sum_{i=1}^r x_i^{2^k}\Big) \,\text{mod}\,2.$$
On the other hand, again by induction (on $|S|$) if we do the expansion $$\prod_{k\in S}\sum_{i\in [r]}c(k,i)=\sum_{\iota\in [r]^S}\prod_{k\in S}c(k,\iota(k))$$ for $\prod_{k\in S} \Big( \sum_{i=1}^r x_i^{2^k}\Big)$, we see that all the $r^{|S|}$ terms of the expansion are different from each other, so that it is a $\{0,1\}$-coefficient polynomial, namely $\displaystyle \sum_{\alpha\in\mathbb N^r,\, |\alpha|=n}\Big[\big( {n \atop \alpha }\big)\text{mod}\,2 \Big]x^\alpha$.
Notation: As usual, for $x=(x_1,\dots,x_r)\in \mathbb R^r$ and $\alpha=(\alpha_1,\dots,\alpha_r)\in \mathbb N^r$ we denote $x^\alpha:=x_1^{\alpha_1}\cdots x_r^{\alpha_r}$, $|\alpha|:=\alpha_1+\dots+\alpha_r$, and $\big({|\alpha| \atop \alpha }\big):=\frac{|\alpha|!}{\alpha_1!\cdots\alpha_r!}$.