A couple of observations:
If the paycheck has a date on January 2018 then the salary, 401K, and contribution from the company are for 2018.
Some companies auto enroll their employees into the 401K. Though there are ways to prevent this my explicitly filling out a form and setting your contribution rate to 0% or $0 per month.
Some companies automatically make a company contribution. Some do it per paycheck, some do it in a lump sum. The lump sum contributions frequently are done in the last paycheck of the year or the first check of the new year. If somebody resigns before that check, they don't get the company contribution.
The IRS considers two types of Employer contributions
Employer contributions
Employer matching contributions. If the plan document permits, the employer can make matching contributions for an employee who
contributes elective deferrals (for example, 50 cents for each dollar
deferred). Employer matching contributions can be discretionary
(contributed in some years and not in others, depending on the
company’s decision) or mandatory, as in SIMPLE plans and Safe Harbor
401(k) plans.
Employer discretionary or nonelective contributions. If the plan document permits, the employer can make contributions other than
matching contributions for participants. These contributions are made
on behalf of all employees who are plan participants, including
participants who choose not to contribute elective deferrals.
Many employees are concerned about the maximum contribution they can make. This total of $18K in 2017 and $18.5K in 2018 includes all employee contributions made to all employers. But there is another limit that is less understood, how employer contributions fit into these limits.
From retirement topics-401k and profit sharing plan contribution limits
Overall limit on contributions
Total annual contributions (annual additions) to all of your accounts
in plans maintained by one employer (and any related employer) are
limited. The limit applies to the total of:
elective deferrals (but not catch-up contributions)
employer matching contributions
employer nonelective contributions
allocations of forfeitures
The annual additions paid to a participant’s account cannot exceed the
lesser of:
100% of the participant's compensation, or
$55,000 ($61,000 including catch-up contributions) for 2018; $54,000 ($60,000 including catch-up contributions) for 2017.
However, an employer’s deduction for contributions to a defined
contribution plan (profit-sharing plan or money purchase pension plan)
cannot be more than 25% of the compensation paid (or accrued) during
the year to eligible employees participating in the plan (see Employer
Deduction in Pub 560, Retirement Plans for Small Business (SEP,
SIMPLE, and Qualified Plans).
So it appears that Company B, can contribute $2800 as a nonelective contribution for 2017, even if you make $0 contributions yourself.