Method and apparatus for glueing or moulding of substrates