Genre is a contract between film and audience. The slasher film, the romantic comedy, the western — each makes implicit promises about what will happen and how.
Genre conventions can be honored (fulfilling the contract), subverted (making audiences aware of the contract's existence), or violated (breaking the contract in ways that may be interesting or alienating).
The most interesting films often work in the tension between genre expectation and deviation. The audience experiences the deviation against the background of the expected, which wouldn't be possible if the expectation weren't established first.