Each row cycles the same rectangular frame (purple top, red bottom, green left, orange right) while the diagonal inside the frame alternates by column: first teal, then red, then teal.
In the bottom row, the first two tiles already follow this sequence (teal, red); hence the third must be the full frame with a red diagonal. Option (D) matches this exactly.