Can open-source libraries be used in a commercial product?
Usually yes, and almost every modern product relies on them. But each open-source library has a licence, and not every licence allows use on any terms: some require the product's code to be opened or the authors to be credited. That is why licences are checked before a library is added, and the libraries themselves are updated regularly and checked for known vulnerabilities.
More in the guide to choosing a tech stack.