I assume you mean US immigration, as this is not a customs issue. USCIS doesn't care about what you do outside US regarding work.
Whether or not you violated "Country A" laws is not a matter for this board, but I would suspect that you did.
However, note what I said about taxes while working in Canada for a US company. The company simply cannot treat you like you are working in US, since you are not. Canada expects taxes to be paid on Cdn employment to canada first, as well as EI and CPP by both the worker and the employer.