What is the relationship between expected occurrences and probability of X number of occurrences This question is related to these previous questions:
Probability of finding 5-nucleotide long sequence in random sequence
Probability of having a specific k-mer in a randomised sequence of length 13
In general when looking for the probability of finding a sequence length m within a larger sequence of length M (sequence of nucleotides in this case) you can find the expected number of occurrences in a sequence. Assuming the sequence cannot self overlap, for M = 13 and m = 6, the expected number of occurrences is the probability of the sequence occurring times the number of positions the sequence can occupy within the larger sequence. For a 6 nucleotide sequence with 4 possible bases, assuming equal likelihood of any base the probability of a random 6 nucleotide sequence being the specified 6 nucleotide sequence is $4^{-6}$. Since the larger sequence has 13 positions, there are $13 - 6 + 1$ = 8 start positions for a 6 nucleotide sequence in the larger sequence. Thus the expected number of occurrences is  (probability of the sequence occurring in a random 6 length sequence) x (number of locations it can occur) =  $(4^{-6}) \times 8 = 2^{-9}$.
I understand that this is the expected number of occurrences, that if we randomly generated an infinite number of 13 length sequences, we would expect an average of 2^-9 occurrences per one randomly generated 13 length sequence. In the examples given, the answerer then goes on to subtract the probability that the sequence occurs exactly twice, and since it cannot self overlap and cannot occur more than twice, we are left with the probability that the sequence occurs exactly once. Can someone explain to me the logic behind why if we take the expected number of occurrences and subtract the number of ways you can get more than one occurrence, we are left with the probability of exactly one occurrence.
Is there another way to conceptualize expected number of occurrences other than the conceptualization I gave above?
 A: In general, if you have an integer value random variable which takes the values $0$ with probability $p_0$, and takes the value $1$ with probability $p_1$, and so on, then the expected value is
$$
p_1+2p_2+3p_3+4p_4+\dots
$$
However, in the two specific examples you linked, it was impossible for there to be three or more occurrences. The first example was a string of length $14$ with a pattern of length $5$, while the second was a string of length $13$ with a pattern of length $6$. In both cases, the patterns could not overlap, so there was only room for two occurences. Therefore, in these cases,
$$
\text{expected # occurrences} = p_1+2p_2\color{gray}{+3\cdot 0+4\cdot 0+\dots}
$$
Also,
\begin{align}
P(\text{at least one occurrence})&=p_1+p_2\color{gray}{+0+0+\dots}\\
P(\text{more than one occurrence})&=p_2\color{gray}{+0+0+\dots}
\end{align}
These two equations make it clear that
$$
P(\text{at least one occurrence}) = (\text{expected # occurrences}) - P(\text{more than one occurrence})
$$
