Electrical control of magnetization is of crucial importance for integrated spintronics devices. Spin-orbit torques (SOT) in heavy-metal/ferromagnetic heterostructures have emerged as promising tool to achieve efficiently current-induced magnetization reversal. However, the microscopic origin of the SOT is being debated, with the spin Hall effect (SHE) due to nonlocal spin currents and the spin Rashba-Edelstein effect (SREE) due to local spin polarization at the interface being the primary candidates. We investigate the electrically induced out-of-equilibrium spin and orbital polarizations in pure Pt films and in Pt/3d-metal (Co, Ni, Cu) bilayer films using ab initio electronic structure methods and linear-response theory. We compute atom-resolved response quantities that allow us to identify the spin-polarization contributions dominantly due to the SHE and SREE and to compare their relative magnitude as well as Pt-layer thickness dependence. We find that the resulting SOT at the Pt/Co and Pt/Ni interface contains contributions from both the nonlocal SHE and local SREE-like components, with the former contributing more at the Pt interface layer and the latter more in the Co or Ni layers. The electrically-induced orbital polarization is nearly completely due to the orbital Hall effect.