The attorney files the motion and the government presents a witness to testify about what happened when the statement was made. The defense attorney has an opportunity to ask questions of the witness. An experienced defense attorney uses questions designed to show that the witness, most likely a police officer, violated the law in obtaining the statements.
There can be written motions where the judge does not need to hear from a witness to testify about the request. Those types of issues are worked out at a motions hearing.