Note that this answer is culture-dependant and my experiences will probably not fit directly with the situation in an American university, which you described to be enrolled in. However, the answer can help understand situations in which the described inofficial arrangements can work out, and also outlines why your situation is rather different from those.
As far as I know, it is very common to pad payment as described for smaller student jobs, so in the end the actual work hours and the actually received sum of payment match. Reasons include:
- University administration/HR departments tend to be (considerably) less spontaneous than what is sometimes required for fulfilling certain research-related tasks. This can become particularly discriminatory towards foreign students, as they might have to wait for documents from other agencies outside of the university (e.g. the agency responsible for foreigners in the respective jurisdiction).
- Workload created by ongoing research is by no means balanced in any way.
- The time available to students is not balanced in any way.
- In contrast to the two above points, student work contracts are often not sophisticated enough to account for that variation. They assume a uniform workload such as n hours a week.
Evidently, these issues can create a severe discrepancy between what is confirmed on paper (e.g. "4 hours a week for 3 months starting in July") and what both parties directly involved in the research want to agree upon to their mutual satisfaction (also with respect to not impeding the student's studying). Hence, it seems, distributing actual work hours differently to what the contract says is a way to counteract the negative effects of bureaucracy both towards research projects and the preferences of the people involved, and therefore not ethically problematic.
However, all of these arrangements usually work because they are conducted by people who responsibly handle the relatively large inofficial leeway. In your particular situation, I do see some warning signs that your superiors might not belong to that group, which indeed evokes the question “Why the world did you not just quit?” for me:
- There was no clear agreement between your superior and you about the inofficial arrangement before it started. It seems your superior 'feels bad about [you] working all this time and wants to "make it up"' as late as you have been working for a considerable number of hours.
- Your superior apparently did nothing to change things earlier. The contractual definition of work hours is, among other things, meant as a protection for the employee from negative side-effects (working too much; having too little time for studying; ...). It can seem justified to bend the rules for the reasons described above, but then the responsibility to protect the employee is passed on to the employer's "manual control". When they learn your officially paid hours are not just behind the actual working time by a week or two, but that no payment is in sight yet, it is up to your superior to tell you to pause working and to try and influence HR themselves.
- Rather than knowing more or less the deviation between what the contract says and what actually happens, you were repeatedly told you 'would start being payed “Just next week”'. While it may have been HR telling you that, this should have been another reason for your superior to suspend the inofficial arrangement for the time being, because obviously it cannot be implemented within parameters known to both of you (given that the parameter of how long you will actually have to wait was totally unknown).
As a final remark, you say you "have been told to not let anyone else know or there will be trouble for it". It is not quite clear how this request was phrased and what is meant by "trouble", or especially, who the "trouble" would be directed at. If this is meant to be "trouble" for you you are right to consider this quite shady, as apparently, your superior is not going to take responsibility for the arrangement1 on the off-chance that anyone complains, and maybe also that the number of hours you amassed is substantial enough that someone might indeed bother to investigate.
1: At the very least, by describing the arrangement as a way to retroactively make up for the due payment the student missed due to unforeseen administrative issues. IANAL, but while probably a violation of procedures of some kind, it seems unlikely anyone would bother to create consequences as there is no tangible damage if the student is paid for the worked time eventually.