This can be explained by the concept of Mendelian genetics of two alleles in a gene for colouring, with a dominant and recessive colouring trait allele.
Here, the black guinea pigs could have the BB or Bb gene whereas the albino guinea pig can only have the bb gene.
The first cross was BB Xbb, resulting in 12 offspring all with a Bb genotype, and hence all black. In the second cross, a black guinea pig was crossed with an albino guinea pig:
BbXbb, resulting in a combination of Bb and bb genes, and hence some albino offspring.