According to your build configuration, your opencv library has been built with avx2 and avx512 support. Those optimized functions are runtime dispatched.
But for your own code, i.e. your source files and makefiles, you have to add compiler options (-mavx2 for g++, or /arch:AVX2 for msvc) for the wanted instruction sets to make those SIMD predefined macros to work. This is not necessary unless you want to write your own SIMD code.