Sonos Inc.’s product introductions and marketing improvements helped it top sales expectations in the latest quarter, and the maker of speakers is feeling optimistic about the year ahead even as recent tariffs are expected to negatively impact results.