First, count the number of each nucleotide in the sequence, and divide that by the total number of all four nucleotides in the sequence. For the C. elegans genome these frequencies will be approximately:
A = 0.32
C = 0.18
G = 0.18
T = 0.32
These frequencies should sum to 1.00.
If you select one nucleotide at random from that DNA sequence then those frequencies become the probabilities for selecting a specific nucleotide at that site. So very roughly you would be twice as likely to get back an A or a T (compared to a G or a C).
Next count the number of each of the 16 possible dinucleotides (e.g., AA, AC . . . TG, TT) in that DNA sequence and divide the numbers by the total number of nucleotides in the sequence. That will give you the observed frequencies of the dinucleotides. CG (or CpG in your post) is one of these. If CG occurs proportionally to the frequencies of C and G then if you picked a random dinucleotide from the sequence you would expect the probability to be 0.18 * 0.18. You can do this same calculation for all of the dinucleotides in a genomic sequence and compare the observed frequencies to the expected frequencies.
If every site is truly random in the sequence then the observed dinucleotide frequencies should be identical to the expected frequencies, and this would be a zero order Markov chain. In fact, genomic DNA is usually not accurately modeled as a zero order Markov chain.