I am facing the following problem:
What is the probability that there will be at least three same consecutive right answers in a $n$-question A/B/C/D test?
I have started with $10$ questions while trying to solve this, so there are $4^{10}$ possible sequences. Now our three same results can begin at the first through the eighth place ($n-2$) because at the ninth place it would be $9-10-11$. For each of these possibilities there can be $4^{10-3} = 4^7$ combinations of $7$ remaining positions. So that's $8 \cdot 4^7$, and now we have to multiply by $4$ because there can be three or more As, Bs, Cs or Ds. That gives us $$\frac{8 \cdot 4^7 \cdot 4}{4^{10}}$$ which simplifies to $8/4^2 = 1/2 = 50\%$.
I have checked the result practically with Python code with $100,000$ attempts, and I got about $38514/100000 = 0.38514 = 38.514\%$, which is not even remotely close to my result.
Do you have any idea where I went wrong?
I think a better approach to this problem is to count the number of strings that do not have three consecutive answers the same. Rather than trying to compute them directly, which will involve us in double-counting problems of the kind you encountered, let's try to develop a recurrence relation. Call a string of characters from {A,B,C,D} "good" if no three consecutive characters are the same, and let $a_n$ be the number of good strings with $n$ characters. If we know $a_n$ can we compute $a_{n+1}?$
Since a the first $n$ characters of a good string length $n+1$ must form a good string of length $n$, we can just add another character to a good string of length $n$ to a get a good string of length $n+1$ provided the last two characters are different. So, let $s_n$ be the number of good strings of length $n$ that end in a single character (that is, the last two character are not the same), and let $d_n$ be the number of good strings of length $n$ that end in a double character. Clearly, $$a_n=s_n+d_n\tag 1$$
Now, to get a good string of length $n+1$ without a doubled character from a good string of length $n$, we simply append any character different from the last one: $$s_n=3a_{n-1}=3(s_{n-1}+d_{n-1})\tag 2$$ To get a doubled string of length $n$ we must add a character different from the last one to a single string of length $n-1$ so that $$ d_n=s_{n-1}\implies s_n=3a_{n-1}=3(s_{n-1}+s_{n-2})\tag 3$$
We know that $s_1=4$ and $s_2=12,$ so we can repeatedly apply $(3)$ to compute the values of $s_n$. I got $s_9=141264, s_{10}=535572,$ from which I computed the probability of three consecutive identical answers as $.3545188903808594\approx 35.45$%
I don't guarantee the correctness of these calculations, as I have not checked them carefully, but they are certainly a lot closer to your experimental results.
I meant to mention that it is possible to solve the recurrence for $s_n$ in closed form, but it's hardly worth the effort for this problem.