I am trying to solve the following difference equation by writing it in closed-form, which represents the probability that a person flips an even number of heads in $n$ tries, with $p$ being the probability that a person flips a head at any given time: $p_{n} = p(1 - p_{n-1}) + (1 - p)p_{n-1}$.
To derive this equation, I did a simple case analysis. There are 2 cases that $n$ flips yields an even number of heads:
odd # of heads $n - 1$ times, then a head: $(1 - p_{n - 1})p$
even # of heads $n - 1$ times, then a tail: $p_{n-1}(1 - p)$
Adding the cases up yields the difference equation I wrote above.
My strategy was to derive the characteristic equation, as this is a non-homogeneous linear equation:
$p_{n} = p - pp_{n-1} + (1 - p)p_{n-1}$
$p_{n} = (1 - 2p)p_{n-1} + p$
$x = (1 - 2p)$
$p_{n} = C(1-2p)^{n}$
We know that $p_{1} = p$:
$C(1 - 2p) = p$
$C = \frac{p}{1 - 2p}$
And plugging back into the original equation, we get:
$p_{n} = \frac{p}{1 - 2p}(1 - 2p)^n = p(1 - 2p)^{n - 1}$.
However, this does not seem to be correct, because if $p$ is $1/2$ (if it is a $1/2$ chance of getting a head on a flip), $p_{n}$ will always be 0.
Your recurrence
$$p_n=(1-2p)p_{n-1}+p$$
is correct, but you seem to have lost track of the $p$ term when you solved it. For convenience let $c=1-2p$, so that the recurrence is $p_n=cp_{n-1}+p$. Let $a_n=p_n-d$ for some constant $d$ that will be determined later; the recurrence can then be written
$$a_n+d=c(a_{n-1}+d)+p\,.$$
Rewrite this as
$$a_n=ca_{n-1}+[(c-1)d+p]$$
and choose $d$ to eliminate the expression in square brackets:
$$d=\frac{p}{1-c}=\frac{p}{1-(1-2p)}=\frac12\,.$$
Then $a_n=ca_{n-1}$, and $p_0=1$ (after $0$ tosses you’re bound to have $0$ heads, an even number), so
$$a_n=c^na_0=c^n(p_0-d)=\frac12c^n$$
for each $n\ge 0$, and
$$p_n=a_n+\frac12=\frac12(c^n+1)=\frac12\big((1-2p)^n+1\big)\,.$$
When $p=\frac12$ we have $p_0=1$ (because $0^0=1$) and $p_n=\frac12$ for all $n\ge 1$, as expected. When $p=0$ we have $p_n=1$ for all $n\ge 0$, again as expected: we’ve always tossed $0$ heads. And for $p=1$ we have $p_n=1$ when $n$ is even and $p_n=0$ when $n$ is odd, yet again as expected.