You started out just fine by counting the following kinds of numbers:
___ ___ ___ ___ ___ ___ ___
6 6 6 1
6 6 6 2
6 6 6 3
6 6 6 4
6 6 6 5
And you’re right that you have to adjust for overcounting. Think of it this way, you’ve counted the numbers in the set $S_1$ of numbers $666????$, $S_2$ of numbers $?666???$, and so on. There are $10,000$ in each set. (Let’s assume ID numbers can begin with the digit $0$.)
Some numbers, however, are in more than one set. There are two kinds of these numbers: the numbers with $4$ or more consecutive sixes and the numbers with two separated groups of consecutive sixes. Let’s use X to mean a non-6 digit and count, beginning with those that have $4$, but not $5$, consecutive sixes.
Numbers of the form $6666X??$ are in $S_1$ and $S_2$.
Numbers of the form $X6666X?$ are in $S_2$ and $S_3$.
Numbers of the form $?X6666X$ are in $S_3$ and $S_4$.
Numbers of the form $??X6666$ are in $S_4$ and $S_5$.
There are 900+810+810+900 of these, and they were counted twice, so we need to subtract $3,420$ from your initial count of $50,000$. Now those with $5$, but not $6$ consecutive sixes. (We haven't considered them in the previous calculation.)
Numbers like $66666X?$, $X66666X$, and $?X66666$. Each was counted three times, and there are $90+81+90=261$ of them. So subtract another $522$.
Next, numbers like $X666666$ and $666666X$ were counted four times, and there are $9+9$ of those, so subtract another $3\cdot18$, and $6666666$ was counted five times, so subtract $4$.
Two separated $666$s occur in numbers like $666X666$ and were counted twice, so subtract $9$.
Summarizing, there are $50,000-3,420-522-54-4-9=45,591$ numbers containing $666$, leaving $9,954,009$ 7-digit numbers (possibly starting with one or more zeros) with no string of three sixes.
The mathematical principle (search and you'll find a general way to solve these problems) is called "inclusion-exclusion." Your initial approach is just what you need to get started with it.
Your method both under and over counts. It undercounts by neglecting patterns like $GGBBGB$, it overcounts by both permuting and then repopulating patterns. If, instead, you skip the permutations (which can all be realized through the later repopulation) you would get $2^3\times 3!\times 3!=288$ which is the correct answer (if you disallow the two patterns $GGBBGB,\;BGBBGG$)
The hard part is to get all the possible patterns. I'll do that here:
By looking at the possible strings,starting with $B=boy$, there are five possible types of arrangements: $$\{BGGBGB,\;BGGBBG,\;BGBGBG,\;BGBGGB,\;BGBBGG\}$$
Starting with $G=girl$ we also have five possible arrangements, namely $$\{GBBGBG,\;GBBGGB,\;GBGBGB,\;GBGBBG,\;GGBBGB\}$$
Each of these can be populated in $3!\times 3!=36$ ways, hence $360$.
To elaborate on the counting:
Case I. say we start with $B$. Then the next has to be $G$.
Ia. $BGG...$. Fourth must be $B$, whence $BGGB$ but then either $\fbox {BGGBBG}$ or $\fbox {BGGBGB}$ work.
Ib. $BGB...$. We could have $BGBB$ in which case we must have $\fbox {BGBBGG}$ or we could have $BGBG$ win which case we could have either $\fbox {BGBGGB}$ or $\fbox{BGBGBG}$.
Case II (starting with $G$) is similar.
Best Answer
I'll just consider the case $n=6, m=3$ as mentioned in the OP's comment.
There are $3^6=729$ possible sequences. We want to subtract the number that have $3$ consecutive equal numbers.
There are $4$ positions in which such a sequence can start, and $3$ possible values. The remaining $3$ positions can be filled in $3^3$ ways, giving $12\cdot27=324$.
A sequence with four consecutive equal numbers will have been counted twice, so we must subtract $3\cdot3\cdot3^2=81$.
A sequence with $5$ consecutive equal numbers will have been added in $3$ times and subtracted twice, so it has been counted once, and no adjustment is needed.
A sequence with $6$ consecutive equal numbers has been added in $4$ times and subtracted $3$ times, so again, so adjustment is needed.
Now we have to consider sequences of the form $aaabbb$ with $a\neq b$. These have been added in twice, so we have to subtract them. There are $3$ ways to choose $a$ and then $2$ ways to choose $b$ so there are $6$ such sequences.
All in all, we have $$ 729-(324-81-6)=492$$
EDIT
Actually, it is possible to solve the general case, though it gets messy. Instead of using inclusion and exclusion, we set up a difference equation.
Call a sequence "admissible" if it doesn't contain $3$ consecutive equal characters. Let $a_n$ be the number of $n$-character admissible sequences. Let $b_n$ be the number of $n$-character admissible sequences whose last two characters are different, and let $c_n$ be the number of $n$-character admissible sequences whose last two characters are the same.
We have $$\begin{align} a_n&=b_n+c_n\tag1\\ b_{n+1}&=(m-1)b_n+(m-1)c_n\tag2\\ c_{n+1}&=b_n\tag3 \end{align}$$
$(2)$ is true because we get to an $n+1$-length sequence whose last characters are different by appending any character different from the last to any admissible sequence of length $n$.
$(3)$ is true because to get an admissible sequence whose last two characters are the same, we must duplicate the last character of any admissible sequence whose last two characters are different.
Combining $(2)$ and $(3)$ gives $$b_{n+1}=(m-1)b_n+(m-1)b_{n-1},\tag4$$ a linear, homogeneous, second-order difference equation with constant coefficients. We have the initial values, $b_0=0,\ b_1=m$, and $(4)$ can be solved by standard methods. (It may seem that we should have $b_0=1$, but we need $b_0=0$ in order that $(4)$ give $b_2=m(m-1).$
Once we have solved for $b_n$, we can rewrite $(1)$ and $(2)$ as $$a_n=\frac{b_{n+1}}{m-1}$$
I leave it to you to solve $(4)$.