How do you know if an insignificant P value is because of chance error or because the sample size of the data is too small? I have always thought that an insignificant P value is the product of chance causing variation in the data. However when I was watching a talk on a study, the presenter mentioned how the insignificant P value meant that the sample size of the data was too small to make any conclusions rather the being the product of chance error. How can you tell if an insignificant P value is caused chance error or small sample size then?

Ideally, you would have run a 'power and sample size' procedure
before doing your experiment. Then you you will have known all
along whether you had a good chance of rejecting $H_0$ if an effect of
the desired size leads to rejection.
Of course, when you are working at the 5% level of significance, there is by definition a 5% probability of rejecting a true null hypothesis. So you can never really be absolutely sure you reach
a correct decision.
If you did not do a power and sample size procedure at the design
phase of experimentation, then doing an ad hoc power analysis
is probably better than just wondering. But you need to understand
that an ad hoc power determination cannot be exactly the
same thing as one done at the proper time. Power analyses at the
design phase almost always involve making some guesses, and you
will likely have to make fewer guesses ad hoc---or at least think so.
Perhaps the main reason for avoiding ad hoc power
analyses arises when you fail to reject when you think you are
'entitled' to a rejection. This can tempt some people into
"P-hacking" procedures such as 'suddenly realizing' that you
really intended a one-sided test all along, or dredging through
the data with unwarranted ad hoc tests looking for 'something like'
the 'unfairly withheld' rejection. At any stage of the experimental
procedure, a power analysis is not a guarantee. It is a prudent precaution. If you could figure out whether to reject via a power
analysis, you wouldn't have to do the experiment.
If no effect is found, many of the experimenters (and thier bosses) may be disappointed and intent on finding the reason for no rejection. Somebody (often the project statistician) has to have the guts to say, the real reason no effect was found may be that no effect exists.
