What is the purpose of the 787 engines extending on landing?
Those are the thrust reversers, which cause the engines to produce thrust "backwards" to help slow the aircraft during the landing. 

You can see a close-up video of 787 thrust reversers in operation, including a look at the panels at the back of the engine which block the normal flow of air.

We also have a question How do thrust reversers work on a jet engine, and when should they be used?, which describes their operation in general.