You're telling various parts of the system how to find the opencv support libraries.
What the code does
The instructions that you cite say to add the following line to /etc/ld.so.conf.d/opencv.conf:
/usr/local is in the bash config as well. When you build an application from source, the default install location is in the /usr/local subtree. The two configuration pieces you mention are there to make sure that the rest of the operating system knows to look in /usr/local/... in addition to the other usual places, for various libraries, etc. If you were to install into another location, say /usr or /opt, you'd want to change all those paths accordingly.
/etc/ld.so.conf (and /etc/ld.so.conf.d) are there to tell ld.so(8) where to find shared libraries. Since opencv installs in /usr/local/..., we need to have ld.so look in /usr/local/lib to find the support libraries for the app. Similarly for pkgconfig, we need to be sure the pkg-config app can find its support files.
Do you need to do this?
Now, you may not need to make the change suggested by the documentation. If you look at the other files in /etc/ld.so.conf.d, you may find that another file already includes /usr/local/lib:
grep /usr/local/lib /etc/ld.so.conf.d/*
On my system, this returns
Because this is here, I wouldn't need a second entry, although it's safe to have it in twice. You may not need the PKG_CONFIG setup either, since the pkg-config(1) man page states:
On most systems, pkg-config looks in /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig for these files.