well in the first place, you never lose the property of being a perfect square by modding out. so since 4 is a perfect square in the integers 4 = 2^2, it willk always be a perfect square modulo any integer. so that one question was a little naive.
then as to other more interesting cases like 5 mod 1234, i think there is a theory due to gauss which cuts the problem in half, at least when perhaps prime moduli are involved? called quadratic reciprocity. i.e. one number is a square modulo another if and only if the other is (or sometimes is not) a square modulo the other?
check this out. it is a major result. but higher degree problems do not enjoy the symmetry and simplicity of squaring problems.
here is the reciprocity theorem from one of the sites given above:
Number Theory Reciprocity Theorems
Quadratic Reciprocity Theorem
Also called the aureum theorema (golden theorem) by Gauss. If p and q are distinct odd primes, then the congruences
x^2 cong to p (mod q) and x^2 cong to q (mod p)
are both solvable or both unsolvable unless both p and q leave the remainder 3 when divided by 4 (in which case one of the congruences is solvable and the other is not).
thus for example, since 29 is congruent to the square 4 mod 5, we have 29 is a square mod 5, so then 5 is also a square mod 29, without having to find the square root. in fact 11^2 = 121 = 5 + 4(29) is congruent to 5 (mod 29). so mod 29, 11 is a square root of 5.
then if we ask whether 5 is a square, not mod 1234, but mod half of that, say mod 617, then since 617 is cong to 2 mod 5, and since 2 is not a square mod 5, it follows that 5 is not a square mod 617. hence 5 cannot be a square mod 1234 either, so in fact there is a method for solving your original problem. i.e. if x satisfies x^2 = (1234)n + 5, then x also satisfies x^2 = (617)(2n) + 5. since the second equation has no solution, neither does the first.
there is no such trick known to me for solving cubic equations or higher degree ones. indeed the study of cubic equations is called the theory of elliptic curves and is a huge subject of study even today, with ramifications in the proof of fermat's last theorem.