Compilation questions

I think you mean that you get the message "BMP280 sensor initialization failed" on the serial monitor , and not that you get a compilation error.

Probably because you're using a constructor of this library that works with an SPI version of the sensor, but your sensor module suggests you are using an I2C version.
See this example for the I2C version you should be using: Adafruit_BMP280_Library/examples/bmp280_sensortest/bmp280_sensortest.ino at master · adafruit/Adafruit_BMP280_Library · GitHub