There are two ways to show a product just on the product page without showing it on the category page or search page.
- remove all categories from the product
- use my module
Show a product just on the product page by removing all categories
it is too easy but let me do it step by step
1-Login to the Magento admin panel
2- Click `catalog > product` on menu
3- set product visibility on “catalog”

4 – remove all the product categories

by this way your product show only on the product page.
We have 4 choices for product visibility.
“Not Visible Individually” : it does not show products on your Magento shop at all
“Catalog” : it show products just on categories page.
“Search” : it show products when a customer will use Magento search and on the search page.
“Catalog, Search”: it is a combination of “catalog” and “search”.
If there are a lot of products you can use the “update attribute” action.
Show a product just on the product page by a Magento module
I wrote a Magento module that will add new product visibility to the Magento products.
By this module you did not need to remove product categories .

It was published on the GitHub https://github.com/gh-darvishani/product-visibility.
composer require darvishani/product-visibility:"dev-master"
I hope it will be useful for you