Does classification of a problem also require the algorithm used? Just learnt that a problem in computer science can be divided into the following categories

Polynomial problems
NP problems
NP hard problems
NP complete problems


based on how long it takes to run the program

For example, suppose there is a problem P that can be solved with two algorithms say A1 and A2 where,

A1 is polynomial in nature,
A2 is non-polynomial


According to me, if P is solved using A1, then P is a polynomial problem and if P is solved using A2, then it must be an NP problem.

Am I right?

In other words, is it fair enough to say that classification of a problem does also require the algorithm that is being used to solve it?
No. The classification of problems into complexity classes is based on the amount of resources required to solve the problem, not the resources that some programmer decides to use. If you have a smart algorithm that solves a problem in polynomial time, and a dumb one that uses exponential time, the problem itself is in polynomial time because it can be solved within that resource bound.