Suppose some problem L is in the complexity class P. Then there is some polynomial time algorithm A that decides the problem. We have the following theorem: if A accepts L, then A decides L.
The proof works by noting that if A runs in polynomial time, then there are some non negative constants c, k such that the run time of A is cn^k where n is the size of the input L. So we can construct a polynomial time algorithm A' that calls A and returns 1 if A returns 1 in time<= cn^k, and returns 0 if A takes longer than cn^k to return something. By doing this, we note that if A tries to go into an infinite loop, then A' just halts the process in poly time and returns 0 which implies that A' rejects the compliment of L.
My question is: Why does this proof not work for the complexity class NP? Can we not just say that if L is in NP, then there is a non deterministic poly time algorithm A that decides L, so just define A' as above?