In a nutshell, a 401(k) is a tax-advantaged retirement investment account. You will generally be allowed to contribute as much as $18,000 annually through payroll deduction. You may choose for your contributions to be "traditional" (in which case you don't pay tax on that portion of your income this year, and instead pay tax on the money when you withdraw it), or "Roth" (in which case you do pay tax on that portion of your income this year, but the money then grows tax-free until withdrawn), or some combination of the two types. Your employer may match part of your contributions. Regardless of whether you elected to make traditional or Roth contributions with your own money, matching funds will always be "traditional", with tax owed when the money is withdrawn. Any transactions within the account that result in dividends or capital gains are not taxed; you only pay tax at the time of withdrawal (for traditional money) or never (for Roth money).
Your employer will decide which investment firm will manage the 401(k), and they will also decide which mutual funds will be available as investment options. You are generally stuck choosing between those funds as long as you participate in that 401(k). This is unfortunate because many employers (especially smaller ones) aren't willing or able to give their employees access to low-fee index funds for their 401(k) plans. The silver lining here is that when you leave your employment with that company, you have the option of moving your 401(k) balance to an IRA, where you can select from any index fund or other investment that you want.
The rules I explained about the taxes are nuanced, generally applying to "normal" aged retirees of at least 59½ years of age. Withdrawing prior to this can result in a 10% early withdrawal penalty. There are
a few ways to avoid this penalty when you retire early, but that's a topic for another thread. These rules also assume you will remain in the US. International taxation of US retirement accounts is something I won't touch with a ten-foot pole. Every country has its own tax treaty with the US declaring how these accounts will be treated under both US and local tax law.