泡沫 means 'bubbles' or 'foam' and is used metaphorically for transience, but 泡沫夢幻 is a fixed four-character compound with a stronger literary and philosophical nuance.
夢幻 means 'dreams' or 'illusions', but 泡沫夢幻 combines both bubbles and dreams to emphasize the insubstantial nature of existence.
A yojijukugo combining 泡沫 (bubbles/foam) and 夢幻 (dreams/illusions), reflecting the Buddhist concept of impermanence. The exact historical origin is uncertain, but it is used in classical and literary Japanese.