Should you build the product or find customers first?
Customers, in almost every case. Finding people is the hard part and building is the part founders enjoy, which is exactly why the order gets reversed.
Why the answer is what it is
The exception is a product so unusual that nobody can picture it. Even then, build the smallest version that can be shown, and show it to people who might pay rather than to people who will encourage you.
What this looks like in practice
The best ideas usually come from a job somebody already had. You notice a problem because you lived inside it, not because you brainstormed.
A market that already spends money is easier than a market you have to convince exists. Competition is evidence, not a warning.
Test whether people will pay before building anything. A hundred people saying they like it is worth less than one paying.
Where a mobile app comes into it
If the idea is a shop, the sequence matters: sell first, prove people come back, then build the app. An app before the customers is a cost with nothing to do.