The key is to observe the numbering convention.
Where a multi-point legal statement uses a), b), c) etc. you should theoretically be able to break the sentence at any of those points and it'd still make sense.
You must not:
a) do this, or
b) do that.
In your example there is a point numbered "a)" but you never get to "b)" so effectively we can ignore that. However, there are two inline points numbered "i" and "ii". This is a different numbering convention (i.e. using roman numerals instead of alphabetical characters) to denote that it is distinct. Normally a legal document is formatted in such a way to show that these are distinct. Perhaps that formatting is lost in your quote.
If you break it down you could understand that all of these are true:
Company A shall not engage in actions that are publicly sexual, pornographic, tortious or defamatory
Company A shall not include the Products, Marks or Company B's name in any material, that is publicly sexual, pornographic, tortious or defamatory
Because points (i) and (ii) are sub-points of section (a), they do not apply to any section (b) which may have similarly numbered sub-points of its own.