I found this weird grouping of notes in a song I'm trying to learn and I want to understand why they are played the way they are. I can listen to the song and replicate it but I don't understand why they are played the way they are.
Grace notes are printed in smaller type and don't take any time from the general meter but rather from the main notes around them. They are played shorter than written, enough so that one can fit them into the available space without shortening the main notes to nothingness. They are decorations and can be left off for first practice. There are a few different kinds (some with slashes through them) that differ in how much they are shortened (if at all) and whether they take time from the following or preceding note or pause.
One more thought on grace notes: you haven't told us the composer or genre here, which can make a difference in how grace notes are played. In the "really old days" of Mozart and Haydn, grace notes often indicated playing, gently, the grace note(s) and following note in equal length. For example, grace note plus eighth note played as two 16ths. However, your posted example shows two grace notes leading an eighth, so in almost all cases this indicates playing them as the "slash-type" grace note, very quick and squeezed into the meter as user51480 said.
Later on in history, it became much more the case that grace notes were exclusively the squeezed-in type rather than the divided-time type. Even so, one should take into account who the composer is, what the style and mood of the piece is, and so on.