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?

The question basically asks what the truth is behind the observed p-value. But if we knew the truth we wouldn't need to compute a p-value in the first place!
I leave technical considerations regarding power to the other answers, but here's a bit about significance test logic.
The idea is that there is an underlying data generating process that we cannot observe directly, therefore we can't say what it truly is. We only see the data.
The p-value is a measure computed from the data that measures compatibility of the data with the null hypothesis. (I think that you use the term "chance" to refer to the null hypothesis, which often but not always interprets as something like "only random variation is going on".)
An insignificant p-value means that if the null hypothesis is in fact true, the data look pretty much as they should be expected to look like (regarding the specific test statistic at least; they may look different in other respects). They are compatible with the null hypothesis, they don't deliver evidence against it.
It does not mean that the null hypothesis is true, however. Data generating processes deviating from the null hypothesis may also produce data that look like this. Note also that most statisticians would agree with Box's famous quote that "all models are wrong but some are useful", so actually at best the null hypothesis may be a very good model (i.e. idealised mathematical description) for what's really going on, but never literally true.
The role of the sample size now is this: The larger the sample size, the more information in the data, and the better we can use the data to actually distingush the null hypothesis from alternative models. If you have a low sample size, the data may not only be compatible with the null hypothesis, but also with models that are really quite different (and in a real context would have a very different interpretation). This means that a large p-value doesn't allow to say that we are at least close to the null hypothesis (meaning "chance variation" in some circumstances). If indeed an alternative model is true, larger sample size will make it more likely to observe a significant p-value (that is called "power" of the test). This implies that with a larger sample size, observing an insignificant p-value, we have some evidence that we're at least close to the null hypothesis.
However, note that if in fact the sample size is very small, we cannot tell these apart, i.e. you cannot say whether the p-value is as it is because we're in fact very close to the null hypothesis, or whether it is only because our sample size is too small and in fact an alternative model is appropriate that with a larger sample size would lead to significance. You can only know this collecting a larger sample! Post hoc power calculations do not address this question! What they tell you is, if you want, the degree of distinctiveness of the sample you have, i.e., how far away from the null you may have been without being able to find it. This doesn't mean that this is indeed the case, as in fact your small sample doesn't allow you to distinguish these cases!
Unfortunately there is a catch in significance test logic, which is that if you collect a very large sample, you will quite likely find a significant p-value even if the truth is, though slightly different from the null hypothesis, so close to it that regarding its meaning in the real situation you'd say that it is not in any relevant manner different from the null hypothesis (like, a true parameter may be 0.02 rather than 0, but you'd think that only parameters larger than 0.5 are worth bothering; obviously this depends on the exact situation, meaning of the data etc.). So indeed large samples may lead to significance often even when this is actually meaningless, which means that you always need to look at estimated effect sizes and possibly confidence intervals to say something more relevant than just whether something is "significant".
