In basic explanation first something will be 3D printend and on molecular level structure will be changed into something new. There are special materials, polimers, which structre can be changed only by light and heat.
I bet soon 4D printer will be often as 3D printers.
Some images:








